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.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/spree/responder.rb', line 5 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(:[], 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.
3 4 5 |
# File 'lib/spree/responder.rb', line 3 def on_failure @on_failure end |
#on_success ⇒ Object
Returns the value of attribute on_success.
3 4 5 |
# File 'lib/spree/responder.rb', line 3 def on_success @on_success end |
Instance Method Details
#to_format ⇒ Object
22 23 24 25 |
# File 'lib/spree/responder.rb', line 22 def to_format super && return unless on_success || on_failure has_errors? ? controller.instance_exec(&on_failure) : controller.instance_exec(&on_success) end |
#to_html ⇒ Object
17 18 19 20 |
# File 'lib/spree/responder.rb', line 17 def to_html super && return unless on_success || on_failure has_errors? ? controller.instance_exec(&on_failure) : controller.instance_exec(&on_success) end |