Class: Spree::Responder
- Inherits:
-
ActionController::Responder
- Object
- ActionController::Responder
- Spree::Responder
- Defined in:
- lib/spree/responder.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#on_failure ⇒ Object
Returns the value of attribute on_failure.
-
#on_success ⇒ Object
Returns the value of attribute on_success.
Instance Method Summary collapse
-
#initialize(controller, resources, options = {}) ⇒ Responder
constructor
A new instance of Responder.
- #to_format ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(controller, resources, options = {}) ⇒ Responder
Returns a new instance of Responder.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/spree/responder.rb', line 6 def initialize(controller, resources, ={}) super class_name = controller.class.name.to_sym action_name = .delete(:action_name) if result = Spree::BaseController.spree_responders[class_name].try(:[], action_name).try(:[], self.format.to_sym) self.on_success = handler(controller, result, :success) self.on_failure = handler(controller, result, :failure) end end |
Instance Attribute Details
#on_failure ⇒ Object
Returns the value of attribute on_failure.
4 5 6 |
# File 'lib/spree/responder.rb', line 4 def on_failure @on_failure end |
#on_success ⇒ Object
Returns the value of attribute on_success.
4 5 6 |
# File 'lib/spree/responder.rb', line 4 def on_success @on_success end |
Instance Method Details
#to_format ⇒ Object
23 24 25 26 |
# File 'lib/spree/responder.rb', line 23 def to_format super and return if !(on_success || on_failure) has_errors? ? controller.instance_exec(&on_failure) : controller.instance_exec(&on_success) end |
#to_html ⇒ Object
18 19 20 21 |
# File 'lib/spree/responder.rb', line 18 def to_html super and return if !(on_success || on_failure) has_errors? ? controller.instance_exec(&on_failure) : controller.instance_exec(&on_success) end |