diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-06-02 04:38:28 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-06-02 04:38:28 +0000 |
commit | 6dea52c54e272b4592d1d157c8626003b03fcac1 (patch) | |
tree | 0e9444eee56c4ced2bb1ec08afb737bc50ee1ce3 /actionpack/lib | |
parent | 180edf4146fcfabd2e0573e451adcfa9e781bd63 (diff) | |
download | rails-6dea52c54e272b4592d1d157c8626003b03fcac1.tar.gz rails-6dea52c54e272b4592d1d157c8626003b03fcac1.tar.bz2 rails-6dea52c54e272b4592d1d157c8626003b03fcac1.zip |
Finish custom handling [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4409 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/mime_responds.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/mime_responds.rb b/actionpack/lib/action_controller/mime_responds.rb index 9e598a8bdc..f14500f551 100644 --- a/actionpack/lib/action_controller/mime_responds.rb +++ b/actionpack/lib/action_controller/mime_responds.rb @@ -94,7 +94,7 @@ module ActionController #:nodoc: # and accept Rails' defaults, life will be much easier. def respond_to(*types, &block) raise ArgumentError, "respond_to takes either types or a block, never bot" unless types.any? ^ block - block ||= lambda { |responder| types.each { |type| responder.known(type) } } + block ||= lambda { |responder| types.each { |type| responder.send(type) } } responder = Responder.new(block.binding) block.call(responder) responder.respond @@ -131,13 +131,19 @@ module ActionController #:nodoc: @responses[mime_type] = eval(DEFAULT_BLOCKS[mime_type.to_sym], @block_binding) end end - - def known(mime_type_extension, &block) - custom(Mime.const_get(mime_type_extension.to_s.upcase), &block) - end def any(*args, &block) - args.each { |type| known(type, &block) } + args.each { |type| send(type, &block) } + 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) + else + super + end end def respond |