Class: DeferrableActions::Action
- Inherits:
-
Object
- Object
- DeferrableActions::Action
- Defined in:
- lib/deferrable_actions.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Class Method Summary collapse
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(controller) ⇒ Action
constructor
A new instance of Action.
- #on_failure_execute! ⇒ Object
Constructor Details
#initialize(controller) ⇒ Action
Returns a new instance of Action.
34 35 36 37 |
# File 'lib/deferrable_actions.rb', line 34 def initialize(controller) @controller = controller @action = controller.session.delete :defered_action end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
21 22 23 |
# File 'lib/deferrable_actions.rb', line 21 def action @action end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
21 22 23 |
# File 'lib/deferrable_actions.rb', line 21 def controller @controller end |
Class Method Details
.exists?(session) ⇒ Boolean
30 31 32 |
# File 'lib/deferrable_actions.rb', line 30 def self.exists?(session) !!session[:defered_action] end |
.store(session, method, args) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/deferrable_actions.rb', line 23 def self.store(session, method, args) session[:defered_action] = { method: method, args: args } end |
Instance Method Details
#execute! ⇒ Object
39 40 41 |
# File 'lib/deferrable_actions.rb', line 39 def execute! controller.send(action[:method], action[:args]) end |
#on_failure_execute! ⇒ Object
43 44 45 |
# File 'lib/deferrable_actions.rb', line 43 def on_failure_execute! controller.send("on_failure_#{action[:method]}", action[:args]) end |