mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove method missing use in respond_to
This commit is contained in:
parent
db5a98e6cb
commit
6dc1288111
1 changed files with 23 additions and 4 deletions
|
@ -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
|
||||
|
||||
Mime::SET.each do |mime|
|
||||
generate_method_for_mime(mime)
|
||||
end
|
||||
|
||||
def method_missing(symbol, &block)
|
||||
mime_constant = symbol.to_s.upcase
|
||||
|
||||
if Mime::SET.include?(Mime.const_get(mime_constant))
|
||||
custom(Mime.const_get(mime_constant), &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
|
||||
|
|
Loading…
Reference in a new issue