Class: Imis::Mapper
- Inherits:
-
Object
- Object
- Imis::Mapper
- Defined in:
- lib/imis/mapper.rb
Constant Summary collapse
- FIELD_MAPPING =
{ vessel_examiner: ['ABC_ASC_Individual_Demog', 'Vol_Vessel_Examiner'], mm: ['ABC_ASC_Individual_Demog', 'TotMMS'], mm_updated: ['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) ⇒ Mapper
constructor
A new instance of Mapper.
-
#update(field_name, value) ⇒ Object
Update a member’s data by a single field name Does not require knowing which business object / iMIS-specific field name to use.
Constructor Details
#initialize(api) ⇒ Mapper
Returns a new instance of Mapper.
13 14 15 |
# File 'lib/imis/mapper.rb', line 13 def initialize(api) @api = api end |
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(field_name, value) ⇒ Object
Update a member’s data by a single field name Does not require knowing which business object / iMIS-specific field name to use
Only available for previously-mapped fields
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/imis/mapper.rb', line 22 def update(field_name, value) if FIELD_MAPPING.key?(field_name.to_sym) business_object_name, field = FIELD_MAPPING[field_name.to_sym] api.put(business_object_name, { field => value }) else warn( "Mapper does not know how to handle field \"#{field_name}\".\n\n" \ 'You can use api.put(business_object_name, { field_name => value }) ' \ "if you know the business object and iMIS-specific field name.\n\n" ) unless ENV['TESTING'] raise( Imis::Error::Mapper, "Unrecognized field: \"#{field_name}\". " \ 'Please report what data you are attempting to work with to ITCom leadership.' ) end end |