Module: IntegratedData::Entity

Defined in:
lib/integrated_data/entity.rb,
lib/integrated_data/entity/lookup.rb,
lib/integrated_data/entity/integrator.rb

Defined Under Namespace

Classes: Integrator, Lookup

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



10
11
12
13
# 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

Instance Method Details

#lookup(attribute, id:, identifier: nil, source:, strategy: :call, **options, &extractor) ⇒ Object



26
27
28
# 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 = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# 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