Class: Hydra::RemoteIdentifier::Mapper::Map
- Inherits:
- BasicObject
- Defined in:
- lib/hydra/remote_identifier/mapper.rb
Overview
The Map is responsible for defining which attributes on the target map to the attributes expected in the RemoteService as well as defining how the RemoteService can update the target
Instance Attribute Summary collapse
-
#_getters ⇒ Object
readonly
Returns the value of attribute _getters.
-
#_setter ⇒ Object
readonly
Returns the value of attribute _setter.
-
#service_class ⇒ Object
readonly
Returns the value of attribute service_class.
Instance Method Summary collapse
-
#initialize(service_class, &config) ⇒ Map
constructor
A new instance of Map.
- #inspect ⇒ Object
- #method_missing(method_name, *args, &block) ⇒ Object
Constructor Details
#initialize(service_class, &config) ⇒ Map
Returns a new instance of Map.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/hydra/remote_identifier/mapper.rb', line 69 def initialize(service_class, &config) @service_class = service_class @_setter = nil @_getters = {} @errors = [] config.call(self) if @_setter.nil? @errors << "Missing :set_identifier" end ::Kernel.raise ::Hydra::RemoteIdentifier::InvalidServiceMapping.new(@errors) if @errors.any? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/hydra/remote_identifier/mapper.rb', line 85 def method_missing(method_name, *args, &block) if method_name == :set_identifier @_setter = args.first || block elsif service_class.valid_attribute?(method_name) @_getters[method_name] = args.first || block else @errors << "Invalid mapping #{method_name}" end end |
Instance Attribute Details
#_getters ⇒ Object (readonly)
Returns the value of attribute _getters.
68 69 70 |
# File 'lib/hydra/remote_identifier/mapper.rb', line 68 def _getters @_getters end |
#_setter ⇒ Object (readonly)
Returns the value of attribute _setter.
68 69 70 |
# File 'lib/hydra/remote_identifier/mapper.rb', line 68 def _setter @_setter end |
#service_class ⇒ Object (readonly)
Returns the value of attribute service_class.
68 69 70 |
# File 'lib/hydra/remote_identifier/mapper.rb', line 68 def service_class @service_class end |
Instance Method Details
#inspect ⇒ Object
81 82 83 |
# File 'lib/hydra/remote_identifier/mapper.rb', line 81 def inspect "#<Hydra::RemoteIdentifier::Mapper::Map for #{service_class} (#{__FILE__})>" end |