diff options
author | Yehuda Katz <wycats@gmail.com> | 2008-12-26 23:16:52 -0800 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2008-12-26 23:16:52 -0800 |
commit | 5da3ba12159d2c4fc0680efcf0cad8a31f725122 (patch) | |
tree | 171025033fbebe6d9a16102647bac659a612334b /actionpack/lib | |
parent | 9b2da52914720d87d2c6d6d94f7fab6a86a70daf (diff) | |
parent | f4f8923cf0ef5bd31f9e98cecf4603d0c4bde296 (diff) | |
download | rails-5da3ba12159d2c4fc0680efcf0cad8a31f725122.tar.gz rails-5da3ba12159d2c4fc0680efcf0cad8a31f725122.tar.bz2 rails-5da3ba12159d2c4fc0680efcf0cad8a31f725122.zip |
Merge commit 'rails/master'
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/assertions/selector_assertions.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_controller/mime_responds.rb | 27 |
2 files changed, 24 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/assertions/selector_assertions.rb b/actionpack/lib/action_controller/assertions/selector_assertions.rb index 248ca85994..7f8fe9ab19 100644 --- a/actionpack/lib/action_controller/assertions/selector_assertions.rb +++ b/actionpack/lib/action_controller/assertions/selector_assertions.rb @@ -402,6 +402,7 @@ module ActionController if rjs_type if rjs_type == :insert position = args.shift + id = args.shift insertion = "insert_#{position}".to_sym raise ArgumentError, "Unknown RJS insertion type #{position}" unless RJS_STATEMENTS[insertion] statement = "(#{RJS_STATEMENTS[insertion]})" diff --git a/actionpack/lib/action_controller/mime_responds.rb b/actionpack/lib/action_controller/mime_responds.rb index de704a6a1c..c41bd3ac4b 100644 --- a/actionpack/lib/action_controller/mime_responds.rb +++ b/actionpack/lib/action_controller/mime_responds.rb @@ -140,12 +140,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 |