Class: DatashiftJourney::StateMachines::BranchSequenceMap
- Inherits:
-
ActiveSupport::HashWithIndifferentAccess
- Object
- ActiveSupport::HashWithIndifferentAccess
- DatashiftJourney::StateMachines::BranchSequenceMap
- Defined in:
- lib/datashift_journey/state_machines/branch_sequence_map.rb
Overview
Map a Sequence to its ID, created in form
branch_sequence :other_sequence, [:other_business]
BranchSequenceMap[:branch_sequence] => Sequence([:other_business])
Instance Method Summary collapse
- #add_branch(id, sequence) ⇒ Object
-
#add_or_concat(id, list) ⇒ Object
Create a new Sequence if ID not yet in Map, otherwise add the state list to the existing Sequence.
-
#branches_for(sequence) ⇒ Object
Find the matching branch sequences for a parent Split (first state).
Instance Method Details
#add_branch(id, sequence) ⇒ Object
22 23 24 25 |
# File 'lib/datashift_journey/state_machines/branch_sequence_map.rb', line 22 def add_branch(id, sequence) # puts "DEBUG: ADDING TO SEQ [#{id}] BRANCH #{sequence.inspect}" self[id] = sequence end |
#add_or_concat(id, list) ⇒ Object
Create a new Sequence if ID not yet in Map, otherwise add the state list to the existing Sequence
18 19 20 |
# File 'lib/datashift_journey/state_machines/branch_sequence_map.rb', line 18 def add_or_concat(id, list) key?(id) ? self[id].add_states(list) : add_branch(id, Sequence.new(list.flatten, id: id)) end |
#branches_for(sequence) ⇒ Object
Find the matching branch sequences for a parent Split (first state)
28 29 30 |
# File 'lib/datashift_journey/state_machines/branch_sequence_map.rb', line 28 def branches_for(sequence) values.find_all { |branch| (branch.entry_state && branch.entry_state == sequence.split_entry_state) } end |