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.
7 8 9 |
# File 'lib/emarsys/params_converter.rb', line 7 def initialize(params={}) self.params = params end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
5 6 7 |
# File 'lib/emarsys/params_converter.rb', line 5 def params @params end |
Instance Method Details
#convert_to_identifiers ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/emarsys/params_converter.rb', line 15 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
11 12 13 |
# File 'lib/emarsys/params_converter.rb', line 11 def convert_to_ids params.is_a?(Hash) ? convert_hash_to_ids : convert_array_to_ids end |