Class: ExMachina::Event::Transition
- Inherits:
-
Object
- Object
- ExMachina::Event::Transition
- Defined in:
- lib/ex_machina/event/transition.rb
Instance Attribute Summary collapse
-
#do_after ⇒ Object
readonly
Returns the value of attribute do_after.
-
#do_before ⇒ Object
readonly
Returns the value of attribute do_before.
-
#do_error ⇒ Object
readonly
Returns the value of attribute do_error.
-
#do_failure ⇒ Object
readonly
Returns the value of attribute do_failure.
-
#do_if ⇒ Object
readonly
Returns the value of attribute do_if.
-
#do_success ⇒ Object
readonly
Returns the value of attribute do_success.
-
#do_unless ⇒ Object
readonly
Returns the value of attribute do_unless.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #conditional? ⇒ Boolean
- #from?(status) ⇒ Boolean
-
#initialize(**options) ⇒ Transition
constructor
A new instance of Transition.
- #to?(status) ⇒ Boolean
Constructor Details
#initialize(**options) ⇒ Transition
Returns a new instance of Transition.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ex_machina/event/transition.rb', line 8 def initialize(**) @from = Array(.fetch(:from)).map { |status| normalize(status) } @to = normalize(.fetch(:to)) # optional args @do_if = [:if] @do_unless = [:unless] @do_before = [:before] @do_after = [:after] @do_success = [:success] @do_failure = [:failure] @do_error = [:error] end |
Instance Attribute Details
#do_after ⇒ Object (readonly)
Returns the value of attribute do_after.
6 7 8 |
# File 'lib/ex_machina/event/transition.rb', line 6 def do_after @do_after end |
#do_before ⇒ Object (readonly)
Returns the value of attribute do_before.
6 7 8 |
# File 'lib/ex_machina/event/transition.rb', line 6 def do_before @do_before end |
#do_error ⇒ Object (readonly)
Returns the value of attribute do_error.
6 7 8 |
# File 'lib/ex_machina/event/transition.rb', line 6 def do_error @do_error end |
#do_failure ⇒ Object (readonly)
Returns the value of attribute do_failure.
6 7 8 |
# File 'lib/ex_machina/event/transition.rb', line 6 def do_failure @do_failure end |
#do_if ⇒ Object (readonly)
Returns the value of attribute do_if.
6 7 8 |
# File 'lib/ex_machina/event/transition.rb', line 6 def do_if @do_if end |
#do_success ⇒ Object (readonly)
Returns the value of attribute do_success.
6 7 8 |
# File 'lib/ex_machina/event/transition.rb', line 6 def do_success @do_success end |
#do_unless ⇒ Object (readonly)
Returns the value of attribute do_unless.
6 7 8 |
# File 'lib/ex_machina/event/transition.rb', line 6 def do_unless @do_unless end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
5 6 7 |
# File 'lib/ex_machina/event/transition.rb', line 5 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
5 6 7 |
# File 'lib/ex_machina/event/transition.rb', line 5 def to @to end |
Instance Method Details
#conditional? ⇒ Boolean
30 31 32 |
# File 'lib/ex_machina/event/transition.rb', line 30 def conditional? !do_if.nil? || !do_unless.nil? end |
#from?(status) ⇒ Boolean
22 23 24 |
# File 'lib/ex_machina/event/transition.rb', line 22 def from?(status) from.include?(normalize(status)) end |
#to?(status) ⇒ Boolean
26 27 28 |
# File 'lib/ex_machina/event/transition.rb', line 26 def to?(status) Array(to).include?(normalize(status)) end |