class FlexCommerceApi::JsonApiClientExtension::IncludedData
Public Class Methods
new(result_set, *args)
click to toggle source
Calls superclass method
# File lib/flex_commerce_api/json_api_client_extension/included_data.rb, line 6 def initialize(result_set, *args) super(result_set, *args) @result_set = result_set end
Private Instance Methods
record_for(link_def)
click to toggle source
attempt to load the record from included data first, failing that, look in the root resource(s) for the record
# File lib/flex_commerce_api/json_api_client_extension/included_data.rb, line 15 def record_for(link_def) data.dig(link_def["type"], link_def["id"]) || root_record_for(link_def) end
root_record_for(link_def)
click to toggle source
# File lib/flex_commerce_api/json_api_client_extension/included_data.rb, line 19 def root_record_for(link_def) @result_set.find do |resource| resource.attributes["type"] == link_def["type"] && resource.attributes["id"] == link_def["id"] end end