Class: LetsDoThis::Act

Inherits:
Object
  • Object
show all
Defined in:
lib/lets_do_this/act.rb

Constant Summary collapse

NOTHING_NEW =
{}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAct

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

#errorsObject

Returns the value of attribute errors.



7
8
9
# File 'lib/lets_do_this/act.rb', line 7

def errors
  @errors
end

#performedObject

Returns the value of attribute performed.



7
8
9
# File 'lib/lets_do_this/act.rb', line 7

def performed
  @performed
end

#resultObject

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

Returns:

  • (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

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/lets_do_this/act.rb', line 14

def instructions(_stage)
  raise NotImplementedError
end

#success?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/lets_do_this/act.rb', line 26

def success?
  @performed && @errors.empty?
end