Class: StatefulModelRails::StateMachine::State
- Inherits:
-
Object
- Object
- StatefulModelRails::StateMachine::State
- Defined in:
- lib/stateful_model_rails/state_machine.rb
Class Attribute Summary collapse
-
.after_enter_callbacks ⇒ Object
readonly
Returns the value of attribute after_enter_callbacks.
-
.after_leave_callbacks ⇒ Object
readonly
Returns the value of attribute after_leave_callbacks.
-
.before_enter_callbacks ⇒ Object
readonly
Returns the value of attribute before_enter_callbacks.
-
.before_leave_callbacks ⇒ Object
readonly
Returns the value of attribute before_leave_callbacks.
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Class Method Summary collapse
- .after_enter(&block) ⇒ Object
- .after_leave(&block) ⇒ Object
- .before_enter(&block) ⇒ Object
- .before_leave(&block) ⇒ Object
Instance Method Summary collapse
-
#initialize(parent) ⇒ State
constructor
A new instance of State.
- #name ⇒ Object
- #run_after_enter ⇒ Object
- #run_after_leave ⇒ Object
- #run_before_enter ⇒ Object
- #run_before_leave ⇒ Object
Constructor Details
#initialize(parent) ⇒ State
Returns a new instance of State.
11 12 13 |
# File 'lib/stateful_model_rails/state_machine.rb', line 11 def initialize(parent) @parent = parent end |
Class Attribute Details
.after_enter_callbacks ⇒ Object (readonly)
Returns the value of attribute after_enter_callbacks.
6 7 8 |
# File 'lib/stateful_model_rails/state_machine.rb', line 6 def after_enter_callbacks @after_enter_callbacks end |
.after_leave_callbacks ⇒ Object (readonly)
Returns the value of attribute after_leave_callbacks.
6 7 8 |
# File 'lib/stateful_model_rails/state_machine.rb', line 6 def after_leave_callbacks @after_leave_callbacks end |
.before_enter_callbacks ⇒ Object (readonly)
Returns the value of attribute before_enter_callbacks.
6 7 8 |
# File 'lib/stateful_model_rails/state_machine.rb', line 6 def before_enter_callbacks @before_enter_callbacks end |
.before_leave_callbacks ⇒ Object (readonly)
Returns the value of attribute before_leave_callbacks.
6 7 8 |
# File 'lib/stateful_model_rails/state_machine.rb', line 6 def before_leave_callbacks @before_leave_callbacks end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
9 10 11 |
# File 'lib/stateful_model_rails/state_machine.rb', line 9 def parent @parent end |
Class Method Details
.after_enter(&block) ⇒ Object
30 31 32 33 |
# File 'lib/stateful_model_rails/state_machine.rb', line 30 def self.after_enter(&block) @after_enter_callbacks ||= [] @after_enter_callbacks << block end |
.after_leave(&block) ⇒ Object
20 21 22 23 |
# File 'lib/stateful_model_rails/state_machine.rb', line 20 def self.after_leave(&block) @after_leave_callbacks ||= [] @after_leave_callbacks << block end |
.before_enter(&block) ⇒ Object
25 26 27 28 |
# File 'lib/stateful_model_rails/state_machine.rb', line 25 def self.before_enter(&block) @before_enter_callbacks ||= [] @before_enter_callbacks << block end |
.before_leave(&block) ⇒ Object
15 16 17 18 |
# File 'lib/stateful_model_rails/state_machine.rb', line 15 def self.before_leave(&block) @before_leave_callbacks ||= [] @before_leave_callbacks << block end |
Instance Method Details
#name ⇒ Object
59 60 61 |
# File 'lib/stateful_model_rails/state_machine.rb', line 59 def name self.class.name end |
#run_after_enter ⇒ Object
53 54 55 56 57 |
# File 'lib/stateful_model_rails/state_machine.rb', line 53 def run_after_enter return unless self.class.after_enter_callbacks self.class.after_enter_callbacks.each { |b| parent.instance_exec(self, &b) } end |
#run_after_leave ⇒ Object
41 42 43 44 45 |
# File 'lib/stateful_model_rails/state_machine.rb', line 41 def run_after_leave return unless self.class.after_leave_callbacks self.class.after_leave_callbacks.each { |b| parent.instance_exec(self, &b) } end |
#run_before_enter ⇒ Object
47 48 49 50 51 |
# File 'lib/stateful_model_rails/state_machine.rb', line 47 def run_before_enter return unless self.class.before_enter_callbacks self.class.before_enter_callbacks.each { |b| parent.instance_exec(self, &b) } end |
#run_before_leave ⇒ Object
35 36 37 38 39 |
# File 'lib/stateful_model_rails/state_machine.rb', line 35 def run_before_leave return unless self.class.before_leave_callbacks self.class.before_leave_callbacks.each { |b| parent.instance_exec(self, &b) } end |