Class: JSONAPI::PrimaryResourceIdTree
- Inherits:
-
ResourceIdTree
- Object
- ResourceIdTree
- JSONAPI::PrimaryResourceIdTree
- Defined in:
- lib/jsonapi/resource_id_tree.rb
Instance Attribute Summary
Attributes inherited from ResourceIdTree
#fragments, #related_resource_id_trees
Instance Method Summary collapse
-
#add_resource_fragment(fragment, include_related) ⇒ null
Adds a Resource Fragment to the Resources hash.
-
#add_resource_fragments(fragments, include_related) ⇒ null
Adds each Resource Fragment to the Resources hash.
-
#initialize ⇒ PrimaryResourceIdTree
constructor
Creates a PrimaryResourceIdTree with no resources and no related ResourceIdTrees.
Methods inherited from ResourceIdTree
#fetch_related_resource_id_tree
Constructor Details
#initialize ⇒ PrimaryResourceIdTree
Creates a PrimaryResourceIdTree with no resources and no related ResourceIdTrees
32 33 34 35 |
# File 'lib/jsonapi/resource_id_tree.rb', line 32 def initialize @fragments ||= {} @related_resource_id_trees ||= {} end |
Instance Method Details
#add_resource_fragment(fragment, include_related) ⇒ null
Adds a Resource Fragment to the Resources hash
55 56 57 58 59 60 61 |
# File 'lib/jsonapi/resource_id_tree.rb', line 55 def add_resource_fragment(fragment, ) fragment.primary = true init_included_relationships(fragment, ) @fragments[fragment.identity] = fragment end |
#add_resource_fragments(fragments, include_related) ⇒ null
Adds each Resource Fragment to the Resources hash
43 44 45 46 47 |
# File 'lib/jsonapi/resource_id_tree.rb', line 43 def add_resource_fragments(fragments, ) fragments.each_value do |fragment| add_resource_fragment(fragment, ) end end |