21: def initialize(name, options = {}, &block)
22: @name = name.to_s.downcase.intern
23:
24: @options = options
25:
26:
27: define_method_names
28:
29: method_list = {
30: :intern_method => "from_#{name}",
31: :intern_multiple_method => "from_multiple_#{name}",
32: :render_multiple_method => "to_multiple_#{name}",
33: :render_method => "to_#{name}"
34: }
35:
36: init_attribute(:mime, "text/#{name}")
37: init_attribute(:weight, 5)
38: init_attribute(:required_methods, method_list.keys)
39: init_attribute(:extension, name.to_s)
40:
41: method_list.each do |method, value|
42: init_attribute(method, value)
43: end
44:
45: raise ArgumentError, "Unsupported option(s) #{@options.keys}" unless @options.empty?
46:
47: @options = nil
48:
49: instance_eval(&block) if block_given?
50: end