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_%s" % name,
31: :intern_multiple_method => "from_multiple_%s" % name,
32: :render_multiple_method => "to_multiple_%s" % name,
33: :render_method => "to_%s" % name
34: }
35:
36: init_attribute(:mime, "text/%s" % name)
37: init_attribute(:weight, 5)
38: init_attribute(:required_methods, method_list.keys)
39:
40: method_list.each do |method, value|
41: init_attribute(method, value)
42: end
43:
44: unless @options.empty?
45: raise ArgumentError, "Unsupported option(s) %s" % @options.keys
46: end
47:
48: @options = nil
49:
50: instance_eval(&block) if block_given?
51: end