Class: IntegratedData::Entity::Lookup

Inherits:
Struct
  • Object
show all
Defined in:
lib/integrated_data/entity/lookup.rb,
lib/integrated_data/entity/lookup.rb

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute

Returns:

  • (Object)

    the current value of attribute



3
4
5
# File 'lib/integrated_data/entity/lookup.rb', line 3

def attribute
  @attribute
end

#extractorObject

Returns the value of attribute extractor

Returns:

  • (Object)

    the current value of extractor



3
4
5
# File 'lib/integrated_data/entity/lookup.rb', line 3

def extractor
  @extractor
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



3
4
5
# File 'lib/integrated_data/entity/lookup.rb', line 3

def id
  @id
end

#identifierObject

Returns the value of attribute identifier

Returns:

  • (Object)

    the current value of identifier



3
4
5
# File 'lib/integrated_data/entity/lookup.rb', line 3

def identifier
  @identifier
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



3
4
5
# File 'lib/integrated_data/entity/lookup.rb', line 3

def options
  @options
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



3
4
5
# File 'lib/integrated_data/entity/lookup.rb', line 3

def source
  @source
end

#strategyObject

Returns the value of attribute strategy

Returns:

  • (Object)

    the current value of strategy



3
4
5
# File 'lib/integrated_data/entity/lookup.rb', line 3

def strategy
  @strategy
end

Class Method Details

.cache_keysObject



7
8
9
# File 'lib/integrated_data/entity/lookup.rb', line 7

def cache_keys
  [:identifier, :source, :strategy, :extractor, :options]
end

Instance Method Details

#cache_keysObject



12
13
14
15
16
# File 'lib/integrated_data/entity/lookup.rb', line 12

def cache_keys
  self.class.cache_keys.map do |key|
    send key
  end
end

#extract(data, attribute) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/integrated_data/entity/lookup.rb', line 22

def extract(data, attribute)
  if extractor
    extractor.call data, attribute
  else
    default_extractor data, attribute
  end
end

#perform(value) ⇒ Object



18
19
20
# File 'lib/integrated_data/entity/lookup.rb', line 18

def perform(value)
  source.build(options).public_send(strategy, id, prepare(value))
end