aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/mime_responds.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-18 06:43:37 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-18 06:43:37 +0000
commit9840dc84f1727f91228250b874ba06dc97c631f0 (patch)
tree9e43012b6541901fb95cc406fc95d3babf6db931 /actionpack/lib/action_controller/mime_responds.rb
parent7e46571115735373ad5993468c8891016057fbb2 (diff)
downloadrails-9840dc84f1727f91228250b874ba06dc97c631f0.tar.gz
rails-9840dc84f1727f91228250b874ba06dc97c631f0.tar.bz2
rails-9840dc84f1727f91228250b874ba06dc97c631f0.zip
Allow for respond_to(:html, :js, :xml) (closes #4277) [Caio Chassot]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3919 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/mime_responds.rb')
-rw-r--r--actionpack/lib/action_controller/mime_responds.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/mime_responds.rb b/actionpack/lib/action_controller/mime_responds.rb
index 140209a225..d492b6c258 100644
--- a/actionpack/lib/action_controller/mime_responds.rb
+++ b/actionpack/lib/action_controller/mime_responds.rb
@@ -5,9 +5,11 @@ module ActionController #:nodoc:
end
module InstanceMethods
- def respond_to(&block)
+ 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.send(type) } }
responder = Responder.new(block.binding)
- yield responder
+ block.call(responder)
responder.respond
end
end