0
@@ -6,7 +6,6 @@ module Ardes #:nodoc:
0
alias_method_chain :default_render, :response_for
0
alias_method_chain :template_exists?, :response_for
0
- alias_method_chain :respond_to, :response_for
0
@@ -119,25 +118,31 @@ module Ardes #:nodoc:
0
- # does a response exist for the current action?
0
- self.class.action_responses.keys.include?(action_name.to_s)
0
+ # return the responses defined by response_for for the current action
0
+ self.class.action_responses[action_name] || []
0
+ # respond_to sets the content type on the response, so we use that to tell
0
+ # if respond_to has been performed
0
+ def respond_to_performed?
0
+ (response && response.content_type) ? true : false
0
# we extend template_exists? to return true if a template OR a response exists corresponding to the current action.
0
# This is so that a default render will be triggered when no action, but a repsonse does exist.
0
def template_exists_with_response_for?
0
-
response_exists? || template_exists_without_response_for?
0
+
action_responses.any? || template_exists_without_response_for?
0
- # if the
re are responses for the current action, then respond_to them
0
+ # if the
response.content_type has not been set (if it has, then responthere are responses for the current action, then respond_to them
0
# we rescue the case where there were no responses, so that the default_render
0
# action will be performed
0
def respond_to_action_responses
0
- if !
@respond_to_performed && (responses = self.class.action_responses[action_name]) && responses.any?
0
+ if !
respond_to_performed? && action_responses.any?
0
respond_to do |responder|
0
-
responses.each {|response| instance_exec(responder, &response) }
0
+
action_responses.each {|response| instance_exec(responder, &response) }
0
end rescue Responder::NoResponsesError
0
@@ -149,11 +154,6 @@ module Ardes #:nodoc:
0
default_render_without_response_for unless performed?
0
- def respond_to_with_response_for(*args, &block)
0
- @respond_to_performed = true
0
- respond_to_without_response_for(*args, &block)
0
# included into ActionController::MimeResponds::Responder
0
class NoResponsesError < RuntimeError; end