Class: JSONAPI::ResourceIdTree

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

Overview

A tree structure representing the resource structure of the requested resource(s). This is an intermediate structure used to keep track of the resources, by identity, found at different included relationships. It will be flattened and the resource instances will be fetched from the cache or the record store.

Direct Known Subclasses

PrimaryResourceIdTree, RelatedResourceIdTree

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fragmentsObject (readonly)

Returns the value of attribute fragments.



8
9
10
# File 'lib/jsonapi/resource_id_tree.rb', line 8

def fragments
  @fragments
end

Returns the value of attribute related_resource_id_trees.



8
9
10
# File 'lib/jsonapi/resource_id_tree.rb', line 8

def related_resource_id_trees
  @related_resource_id_trees
end

Instance Method Details

Gets the related Resource Id Tree for a relationship, and creates it first if it does not exist

Parameters:

Returns:



15
16
17
18
# File 'lib/jsonapi/resource_id_tree.rb', line 15

def fetch_related_resource_id_tree(relationship)
  relationship_name = relationship.name.to_sym
  @related_resource_id_trees[relationship_name] ||= RelatedResourceIdTree.new(relationship, self)
end