2009-12-09 17:48:40 +00:00
|
|
|
module SimpleForm
|
2009-12-11 13:53:18 +00:00
|
|
|
Mapping = Struct.new(:method, :collection, :options, :with_priority)
|
2009-12-09 17:48:40 +00:00
|
|
|
|
|
|
|
module MapType
|
|
|
|
def mappings
|
|
|
|
@mappings ||= {}
|
|
|
|
end
|
|
|
|
|
2009-12-10 00:55:42 +00:00
|
|
|
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]
|
2009-12-11 13:53:18 +00:00
|
|
|
mapping = Mapping.new(options[:to], options[:collection] || false,
|
|
|
|
options[:options] || false, options[:with_priority] || false)
|
2009-12-10 00:55:42 +00:00
|
|
|
types.each { |t| mappings[t] = mapping }
|
2009-12-09 17:48:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|