Module: SimpleForm::MapType

Included in:
FormBuilder, Inputs::MappingInput
Defined in:
lib/simple_form/map_type.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



5
6
7
8
# File 'lib/simple_form/map_type.rb', line 5

def self.extended(base)
  base.class_attribute :mappings
  base.mappings = {}
end

Instance Method Details

#map_type(*types) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'lib/simple_form/map_type.rb', line 10

def map_type(*types)
  map_to = types.extract_options![:to]
  raise ArgumentError, "You need to give :to as option to map_type" unless map_to
  types.each { |t| mappings[t] = map_to }
end