diff options
author | Yehuda Katz <wycats@gmail.com> | 2008-12-26 13:37:42 -0800 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2008-12-26 13:41:02 -0800 |
commit | 6dc12881110d26bb952bd0f565623144f10a07b6 (patch) | |
tree | 68c1a4cf50cc28864cf2b72714508e2524798a62 | |
parent | db5a98e6cbb88331a6ce484260e9cce9ba882bcd (diff) | |
download | rails-6dc12881110d26bb952bd0f565623144f10a07b6.tar.gz rails-6dc12881110d26bb952bd0f565623144f10a07b6.tar.bz2 rails-6dc12881110d26bb952bd0f565623144f10a07b6.zip |
Remove method missing use in respond_to
-rw-r--r-- | actionpack/lib/action_controller/mime_responds.rb | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/mime_responds.rb b/actionpack/lib/action_controller/mime_responds.rb index 29294476f7..76fcae5f51 100644 --- a/actionpack/lib/action_controller/mime_responds.rb +++ b/actionpack/lib/action_controller/mime_responds.rb @@ -143,12 +143,31 @@ module ActionController #:nodoc: custom(@mime_type_priority.first, &block) end end + + def self.generate_method_for_mime(mime) + sym = mime.is_a?(Symbol) ? mime : mime.to_sym + const = sym.to_s.upcase + class_eval <<-RUBY + def #{sym}(&block) # def html(&block) + if Mime::SET.include?(Mime::#{const}) # if Mime::Set.include?(Mime::HTML) + custom(Mime::#{const}, &block) # custom(Mime::HTML, &block) + else # else + super # super + end # end + end # end + RUBY + end - def method_missing(symbol, &block) - mime_constant = symbol.to_s.upcase + Mime::SET.each do |mime| + generate_method_for_mime(mime) + end - if Mime::SET.include?(Mime.const_get(mime_constant)) - custom(Mime.const_get(mime_constant), &block) + def method_missing(symbol, &block) + mime_constant = Mime.const_get(symbol.to_s.upcase) + + if Mime::SET.include?(mime_constant) + self.class.generate_method_for_mime(mime_constant) + send(symbol, &block) else super end |