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, force_eager_load: false) ⇒ IncludeDirectives
constructor
Construct an IncludeDirectives Hash from an array of dot separated include strings.
- #model_includes ⇒ Object
- #paths ⇒ Object
Constructor Details
#initialize(resource_klass, includes_array, force_eager_load: false) ⇒ IncludeDirectives
Construct an IncludeDirectives Hash from an array of dot separated include strings. For example [‘posts.comments.tags’] will transform into => {
posts:{
include:true,
include_related:{
comments:{
include:true,
include_related:{
tags:{
include:true
}
}
}
}
}
}
22 23 24 25 26 27 28 29 |
# File 'lib/jsonapi/include_directives.rb', line 22 def initialize(resource_klass, includes_array, force_eager_load: false) @resource_klass = resource_klass @force_eager_load = force_eager_load @include_directives_hash = { include_related: {} } includes_array.each do |include| parse_include(include) end end |
Instance Method Details
#include_directives ⇒ Object
31 32 33 |
# File 'lib/jsonapi/include_directives.rb', line 31 def include_directives @include_directives_hash end |
#model_includes ⇒ Object
35 36 37 |
# File 'lib/jsonapi/include_directives.rb', line 35 def model_includes get_includes(@include_directives_hash) end |
#paths ⇒ Object
39 40 41 |
# File 'lib/jsonapi/include_directives.rb', line 39 def paths delve_paths(get_includes(@include_directives_hash, false)) end |