Module: Eloqua::Helper::AttributeMap::InstanceMethods

Defined in:
lib/eloqua/helper/attribute_map.rb

Instance Method Summary collapse

Instance Method Details

#map_attributes(attributes) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/eloqua/helper/attribute_map.rb', line 53

def map_attributes(attributes)
  @instance_reverse_keys ||= attribute_map_reverse.clone
  results = {}.with_indifferent_access

  attributes.each do |key, value|
    formatted_key = attribute_map.fetch(key) { key.to_s.gsub(/^C_/, '').underscore }
    @instance_reverse_keys[formatted_key] = key
    results[formatted_key] = value
  end
  results
end

#reverse_map_attributes(attributes) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/eloqua/helper/attribute_map.rb', line 65

def reverse_map_attributes(attributes)
  results = {}.with_indifferent_access
  attributes.each do |key, value|
    results[@instance_reverse_keys.fetch(key){key}] = value
  end
  results
end