Class: Hydra::RemoteIdentifier::Mapper::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/hydra/remote_identifier/mapper.rb

Overview

The Wrapper provides the getting and setting behavior for a target based on a Map

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map, target) ⇒ Wrapper

Returns a new instance of Wrapper.



22
23
24
# File 'lib/hydra/remote_identifier/mapper.rb', line 22

def initialize(map, target)
  @map, @target = map, target
end

Instance Attribute Details

#mapObject (readonly)

Returns the value of attribute map.



21
22
23
# File 'lib/hydra/remote_identifier/mapper.rb', line 21

def map
  @map
end

#targetObject (readonly)

Returns the value of attribute target.



21
22
23
# File 'lib/hydra/remote_identifier/mapper.rb', line 21

def target
  @target
end

Instance Method Details

#extract_payloadObject



26
27
28
29
30
31
# File 'lib/hydra/remote_identifier/mapper.rb', line 26

def extract_payload
  map._getters.each_with_object({}) do |(key, getter), mem|
    mem[key] = extract_attribute_for(target, getter, key)
    mem
  end
end

#set_identifier(identifier) ⇒ Object



33
34
35
# File 'lib/hydra/remote_identifier/mapper.rb', line 33

def set_identifier(identifier)
  update_target(map._setter, target, identifier)
end