module IntegratedData::Entity
Constants
- Integrator
- Lookup
Public Class Methods
extended(base;)
click to toggle source
Calls superclass method
# File lib/integrated_data/entity.rb, line 10 def extended base; super base.class_attribute :lookups, instance_accessor: false, instance_predicate: false base.lookups = Set.new end
Public Instance Methods
lookup(attribute, id: , identifier: nil, source: , strategy: :call, **options, &extractor)
click to toggle source
# File lib/integrated_data/entity.rb, line 26 def lookup(attribute, id: , identifier: nil, source: , strategy: :call, **options, &extractor) self.lookups = lookups.dup.add Lookup.new attribute, id, identifier, source, strategy, extractor, options end
new(identifiers={})
click to toggle source
Calls superclass method
# File lib/integrated_data/entity.rb, line 16 def new(identifiers={}) attributes = integrated(identifiers).attributes super(attributes).tap do |entity| entity.class_eval do @identifiers = identifiers @attributes = attributes end end end
Private Instance Methods
available_lookups(identifiers)
click to toggle source
# File lib/integrated_data/entity.rb, line 36 def available_lookups(identifiers) lookups.select do |lookup| identifiers.include? lookup.id end end
integrated(identifiers)
click to toggle source
# File lib/integrated_data/entity.rb, line 32 def integrated(identifiers) Integrator.new(identifiers, available_lookups(identifiers.keys)) end