class IntegratedData::Entity::Integrator
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/integrated_data/entity/integrator.rb, line 8 def initialize(*args) @cache = {} super end
Public Instance Methods
attributes()
click to toggle source
# File lib/integrated_data/entity/integrator.rb, line 13 def attributes Hash[ lookups.group_by(&:attribute).map do |attribute, lookups| [ attribute, find_attribute_for(lookups, attribute) ] end ] end
Private Instance Methods
data_for(lookup, attribute)
click to toggle source
# File lib/integrated_data/entity/integrator.rb, line 27 def data_for(lookup, attribute) if data = perform_lookup(lookup) lookup.extract data, attribute end end
find_attribute_for(lookups, attribute)
click to toggle source
# File lib/integrated_data/entity/integrator.rb, line 33 def find_attribute_for(lookups, attribute) lookups.find do |lookup| data_for(lookup, attribute).tap do |data| return data if data end end end
perform_lookup(lookup)
click to toggle source
# File lib/integrated_data/entity/integrator.rb, line 23 def perform_lookup(lookup) @cache[lookup.cache_keys] ||= lookup.perform(identifiers[lookup.id]) end