Class: JSONAPI::IncludeDirectives
- Inherits:
-
Object
- Object
- JSONAPI::IncludeDirectives
- Defined in:
- lib/jsonapi/include_directives.rb
Instance Method Summary collapse
- #include_directives ⇒ Object
-
#initialize(resource_klass, includes_array) ⇒ IncludeDirectives
constructor
Construct an IncludeDirectives Hash from an array of dot separated include strings.
Constructor Details
#initialize(resource_klass, includes_array) ⇒ IncludeDirectives
Construct an IncludeDirectives Hash from an array of dot separated include strings. For example [‘posts.comments.tags’] will transform into =>
posts: {
include_related: {
comments:{
include_related: {
tags: {
include_related: {
}
}
}
}
}
}
20 21 22 23 24 25 26 |
# File 'lib/jsonapi/include_directives.rb', line 20 def initialize(resource_klass, includes_array) @resource_klass = resource_klass @include_directives_hash = { include_related: {} } includes_array.each do |include| parse_include(include) end end |
Instance Method Details
#include_directives ⇒ Object
28 29 30 |
# File 'lib/jsonapi/include_directives.rb', line 28 def include_directives @include_directives_hash end |