Class: Emarsys::ParamsConverter
- Inherits:
-
Object
- Object
- Emarsys::ParamsConverter
- Defined in:
- lib/emarsys/params_converter.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #convert_to_identifiers ⇒ Object
- #convert_to_ids ⇒ Object
-
#initialize(params = {}) ⇒ ParamsConverter
constructor
A new instance of ParamsConverter.
Constructor Details
#initialize(params = {}) ⇒ ParamsConverter
Returns a new instance of ParamsConverter.
6 7 8 |
# File 'lib/emarsys/params_converter.rb', line 6 def initialize(params={}) self.params = params end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/emarsys/params_converter.rb', line 4 def params @params end |
Instance Method Details
#convert_to_identifiers ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/emarsys/params_converter.rb', line 19 def convert_to_identifiers new_hash = {} params.each do |key, value| matching_attributes = Emarsys::FieldMapping::ATTRIBUTES.find{|elem| elem[:id] == key.to_i && key.to_i != 0} new_hash.merge!({ (matching_attributes.nil? ? key : matching_attributes[:identifier]) => value }) end new_hash end |
#convert_to_ids ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/emarsys/params_converter.rb', line 10 def convert_to_ids new_hash = {} params.each do |key, value| matching_attributes = Emarsys::FieldMapping::ATTRIBUTES.find{|elem| elem[:identifier] == key.to_s} new_hash.merge!({ (matching_attributes.nil? ? key : matching_attributes[:id]) => value }) end new_hash end |