heartcombo--simple_form/lib/simple_form/map_type.rb

17 lines
539 B
Ruby
Raw Normal View History

2009-12-09 17:48:40 +00:00
module SimpleForm
Mapping = Struct.new(:method, :collection, :options, :with_priority)
2009-12-09 17:48:40 +00:00
module MapType
def mappings
@mappings ||= {}
end
def map_type(*types)
options = types.extract_options!
2009-12-09 17:48:40 +00:00
raise ArgumentError, "You need to give :to as option to map_type" unless options[:to]
mapping = Mapping.new(options[:to], options[:collection] || false,
options[:options] || false, options[:with_priority] || false)
types.each { |t| mappings[t] = mapping }
2009-12-09 17:48:40 +00:00
end
end
end