Module: Opal::StateMachine
- Defined in:
- lib/opal/aasm.rb,
lib/opal/aasm/version.rb
Defined Under Namespace
Modules: AASMAPI
Constant Summary collapse
- VERSION =
"0.7.0"
Class Method Summary collapse
-
.extend_react_component(where, klass = nil) ⇒ Object
1 we are required first, we are included first 2 we are required first, we are included second 3 we are required second, we are included first 4 we are required second, we are included second 5 we are required, but they are not.
- .included(base) ⇒ Object
Instance Method Summary collapse
Class Method Details
.extend_react_component(where, klass = nil) ⇒ Object
1 we are required first, we are included first
2 we are required first, we are included second
3 we are required second, we are included first 4 we are required second, we are included second 5 we are required, but they are not
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/opal/aasm.rb', line 20 def self.extend_react_component(where, klass = nil) return if klass and klass.respond_to? :aasm_event_fired # case 4 already handled when we were required. if klass and klass.respond_to? :define_state # case 2 klass.define_state :protected_current_react_state_var klass.define_method :aasm_event_fired do |event, from, to| protected_current_react_state_var! to.to_s if from != to end elsif defined? React::Component # case 3 + 4 (second call from include will be ignored) # case 1 (first call from require will be ignored) React::Component.module_eval do # alias_method does not work on :included so we do it the hard way unless @original_included_method_for_state_machine @original_included_method_for_state_machine = self.method(:included) def self.included(base) @original_included_method_for_state_machine.call(base) base.define_state :protected_current_react_state_var base.define_method :aasm_event_fired do |event, from, to| protected_current_react_state_var! to.to_s if from != to end end end end end end |
.included(base) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/opal/aasm.rb', line 76 def self.included(base) Opal::StateMachine.extend_react_component("StateMachine included", base) base.include AASM base.extend AASMAPI end |
Instance Method Details
#current_state ⇒ Object
47 48 49 50 |
# File 'lib/opal/aasm.rb', line 47 def current_state protected_current_react_state_var if respond_to? :render aasm.current_state.to_s end |