Class: Rung::State

Inherits:
Object
  • Object
show all
Includes:
ValueObject
Defined in:
lib/rung/state.rb

Overview

Execution state. It acts as a Hash.

Created when Operation call starts. Steps can mutate it. Returned in an unchanged form to the user from the call.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ValueObject

#==

Constructor Details

#initialize(state, success, operation) ⇒ State

Returns a new instance of State.


11
12
13
14
15
# File 'lib/rung/state.rb', line 11

def initialize(state, success, operation)
  @success = success
  @operation = operation
  @state = state
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Internal state Hash methods delegation


18
19
20
21
22
# File 'lib/rung/state.rb', line 18

def method_missing(method, *args)
  return @state.send(method, *args) if @state.respond_to?(method)

  super
end

Instance Attribute Details

#operationObject (readonly)

Returns the value of attribute operation


29
30
31
# File 'lib/rung/state.rb', line 29

def operation
  @operation
end

Instance Method Details

#fail?Boolean Also known as: failure?, failed?

Returns:

  • (Boolean)

35
36
37
# File 'lib/rung/state.rb', line 35

def fail?
  !success?
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Internal state Hash methods delegation

Returns:

  • (Boolean)

25
26
27
# File 'lib/rung/state.rb', line 25

def respond_to_missing?(method_name, include_private = false)
  @state.respond_to?(method_name, include_private) || super
end

#success?Boolean Also known as: successful?

Returns:

  • (Boolean)

31
32
33
# File 'lib/rung/state.rb', line 31

def success?
  @success
end