Class: DatashiftJourney::StateMachines::Sequence

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/datashift_journey/state_machines/sequence.rb

Direct Known Subclasses

EmptySequence

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(states, id: '', entry_state: nil, exit_state: nil, trigger_value: nil, trigger_method: nil, split: false) ⇒ Sequence

rubocop:disable Metrics/ParameterLists



34
35
36
37
38
39
40
41
42
43
# File 'lib/datashift_journey/state_machines/sequence.rb', line 34

def initialize(states, id: '', entry_state: nil, exit_state: nil, trigger_value: nil, trigger_method: nil, split: false)
  @states = [*states]

  @id = id
  @entry_state = entry_state
  @exit_state = exit_state
  @trigger_method = trigger_method
  @trigger_value = trigger_value
  @split = split
end

Instance Attribute Details

#entry_stateObject

Returns the value of attribute entry_state.



23
24
25
# File 'lib/datashift_journey/state_machines/sequence.rb', line 23

def entry_state
  @entry_state
end

#exit_stateObject

Returns the value of attribute exit_state.



23
24
25
# File 'lib/datashift_journey/state_machines/sequence.rb', line 23

def exit_state
  @exit_state
end

#idObject (readonly)

Returns the value of attribute id.



21
22
23
# File 'lib/datashift_journey/state_machines/sequence.rb', line 21

def id
  @id
end

#splitObject

Returns the value of attribute split.



25
26
27
# File 'lib/datashift_journey/state_machines/sequence.rb', line 25

def split
  @split
end

#statesObject

Returns the value of attribute states.



23
24
25
# File 'lib/datashift_journey/state_machines/sequence.rb', line 23

def states
  @states
end

#trigger_methodObject

Returns the value of attribute trigger_method.



25
26
27
# File 'lib/datashift_journey/state_machines/sequence.rb', line 25

def trigger_method
  @trigger_method
end

#trigger_valueObject

Returns the value of attribute trigger_value.



25
26
27
# File 'lib/datashift_journey/state_machines/sequence.rb', line 25

def trigger_value
  @trigger_value
end

Instance Method Details

#add_states(list) ⇒ Object



45
46
47
# File 'lib/datashift_journey/state_machines/sequence.rb', line 45

def add_states(list)
  @states.concat(list.flatten)
end

#branch?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/datashift_journey/state_machines/sequence.rb', line 57

def branch?
  !trigger_value.nil?
end

#inspectObject



49
50
51
# File 'lib/datashift_journey/state_machines/sequence.rb', line 49

def inspect
  "#{self.class.name}(#{id}) - #{@states.inspect} [splitter = #{split?}]"
end

#split?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/datashift_journey/state_machines/sequence.rb', line 53

def split?
  split == true
end

#split_entry_stateObject



61
62
63
64
# File 'lib/datashift_journey/state_machines/sequence.rb', line 61

def split_entry_state
  return nil unless split?
  states.first
end