Class: Imis::Mapper
- Inherits:
-
Object
- Object
- Imis::Mapper
- Defined in:
- lib/imis/mapper.rb
Constant Summary collapse
- FIELD_MAPPING =
{ vessel_examiner: %w[ABC_ASC_Individual_Demog Vol_Vessel_Examiner], mm: %w[ABC_ASC_Individual_Demog TotMMS], mm_updated: %w[ABC_ASC_Individual_Demog MMS_Updated] }.freeze
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
-
#initialize(api = nil) ⇒ Mapper
constructor
A new instance of Mapper.
-
#update(data) ⇒ Object
Update a member’s data on multiple affected business objects by arbitrary field names Does not require knowing which business object / iMIS-specific field name to use.
Constructor Details
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
11 12 13 |
# File 'lib/imis/mapper.rb', line 11 def api @api end |
Instance Method Details
#update(data) ⇒ Object
Update a member’s data on multiple affected business objects by arbitrary field names Does not require knowing which business object / iMIS-specific field name to use
Only available for previously-mapped fields
`data` is a hash of shape { field_key => value }
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/imis/mapper.rb', line 24 def update(data) updates = data.each_with_object({}) do |(field_key, value), hash| map_update(field_key) do |business_object_name, field| hash[business_object_name] ||= {} hash[business_object_name][field] = value end end updates.map do |business_object_name, field_updates| api.put_fields(business_object_name, field_updates) end end |