Class: Hydra::RemoteIdentifier::Mapper::Wrapper
- Inherits:
-
Object
- Object
- Hydra::RemoteIdentifier::Mapper::Wrapper
- 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
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #extract_payload ⇒ Object
-
#initialize(map, target) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #set_identifier(identifier) ⇒ Object
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
#map ⇒ Object (readonly)
Returns the value of attribute map.
21 22 23 |
# File 'lib/hydra/remote_identifier/mapper.rb', line 21 def map @map end |
#target ⇒ Object (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_payload ⇒ Object
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 |