Class: LetsDoThis::Act
- Inherits:
-
Object
- Object
- LetsDoThis::Act
- Defined in:
- lib/lets_do_this/act.rb
Constant Summary collapse
- NOTHING_NEW =
{}.freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#performed ⇒ Object
Returns the value of attribute performed.
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
- #failure? ⇒ Boolean
- #follow_instructions!(stage) ⇒ Object
-
#initialize ⇒ Act
constructor
A new instance of Act.
- #instructions(_stage) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize ⇒ Act
Returns a new instance of Act.
9 10 11 12 |
# File 'lib/lets_do_this/act.rb', line 9 def initialize @performed = false @errors = Errors.new end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
7 8 9 |
# File 'lib/lets_do_this/act.rb', line 7 def errors @errors end |
#performed ⇒ Object
Returns the value of attribute performed.
7 8 9 |
# File 'lib/lets_do_this/act.rb', line 7 def performed @performed end |
#result ⇒ Object
Returns the value of attribute result.
7 8 9 |
# File 'lib/lets_do_this/act.rb', line 7 def result @result end |
Instance Method Details
#failure? ⇒ Boolean
30 31 32 |
# File 'lib/lets_do_this/act.rb', line 30 def failure? @performed && @errors.present? end |
#follow_instructions!(stage) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/lets_do_this/act.rb', line 18 def follow_instructions!(stage) tap do _1.performed = true instructions_ = instructions(stage) _1.result = instructions_.is_a?(Hash) ? instructions_ : {} end end |
#instructions(_stage) ⇒ Object
14 15 16 |
# File 'lib/lets_do_this/act.rb', line 14 def instructions(_stage) raise NotImplementedError end |
#success? ⇒ Boolean
26 27 28 |
# File 'lib/lets_do_this/act.rb', line 26 def success? @performed && @errors.empty? end |