Module: ATDIS::TypeCastAttributes::ClassMethods

Defined in:
lib/atdis/model.rb

Instance Method Summary collapse

Instance Method Details

#field_mappings(params) ⇒ Object

of the form Integer, address: String



17
18
19
20
21
22
23
24
25
# File 'lib/atdis/model.rb', line 17

def field_mappings(params)
  define_attribute_methods(params.keys.map(&:to_s))
  # Convert all values to arrays. Doing this for the sake of tidier notation
  self.attribute_types = {}
  params.each do |k, v|
    v = [v] unless v.is_a?(Array)
    attribute_types[k] = v
  end
end