Class: JSONAPI::IncludeDirectives

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/include_directives.rb

Instance Method Summary collapse

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_directivesObject



28
29
30
# File 'lib/jsonapi/include_directives.rb', line 28

def include_directives
  @include_directives_hash
end