class JSONAPI::PrimaryResourceIdTree
Public Class Methods
new()
click to toggle source
Creates a PrimaryResourceIdTree
with no resources and no related ResourceIdTrees
# File lib/jsonapi/resource_id_tree.rb, line 32 def initialize @fragments ||= {} @related_resource_id_trees ||= {} end
Public Instance Methods
add_resource_fragment(fragment, include_related)
click to toggle source
Adds a Resource
Fragment to the Resources
hash
@param fragment [JSONAPI::ResourceFragment] @param include_related [Hash]
@return [null]
# File lib/jsonapi/resource_id_tree.rb, line 55 def add_resource_fragment(fragment, include_related) fragment.primary = true init_included_relationships(fragment, include_related) @fragments[fragment.identity] = fragment end
add_resource_fragments(fragments, include_related)
click to toggle source
Adds each Resource
Fragment to the Resources
hash
@param fragments [Hash] @param include_related [Hash]
@return [null]
# File lib/jsonapi/resource_id_tree.rb, line 43 def add_resource_fragments(fragments, include_related) fragments.each_value do |fragment| add_resource_fragment(fragment, include_related) end end