aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/mime_responds.rb
diff options
context:
space:
mode:
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