Class: Airflow::State

Inherits:
Object
  • Object
show all
Defined in:
lib/async_flow/state.rb

Constant Summary collapse

BG_RUNNER_TRANSITIONS =
{
  init: :init,
  stop: :stopped,
  running: :running
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transitions) ⇒ State

Returns a new instance of State.



17
18
19
20
# File 'lib/async_flow/state.rb', line 17

def initialize(transitions)
  @transitions = transitions
  define_methods
end

Instance Attribute Details

#stateObject

Returns the value of attribute state.



15
16
17
# File 'lib/async_flow/state.rb', line 15

def state
  @state
end

Class Method Details

.bg_stateObject



11
12
13
# File 'lib/async_flow/state.rb', line 11

def self.bg_state
  new(BG_RUNNER_TRANSITIONS)
end

Instance Method Details

#state?(state) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/async_flow/state.rb', line 22

def state?(state)
  public_send("#{state}?")
end

#transition!(new_state) ⇒ Object



26
27
28
# File 'lib/async_flow/state.rb', line 26

def transition!(new_state)
  public_send("#{new_state}!")
end