Class: Stateoscope::Integrations::AASM

Inherits:
Struct
  • Object
show all
Defined in:
lib/stateoscope/integrations/aasm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#klassObject

Returns the value of attribute klass


3
4
5
# File 'lib/stateoscope/integrations/aasm.rb', line 3

def klass
  @klass
end

#state_machine_nameObject

Returns the value of attribute state_machine_name


3
4
5
# File 'lib/stateoscope/integrations/aasm.rb', line 3

def state_machine_name
  @state_machine_name
end

Instance Method Details

#full_state_machine_nameObject


24
25
26
27
28
29
30
# File 'lib/stateoscope/integrations/aasm.rb', line 24

def full_state_machine_name
  [
    "aasm",
    klass.name,
    state_machine_name
  ].compact.join('-').dasherize
end

#graphObject


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/stateoscope/integrations/aasm.rb', line 4

def graph
  graph = Graph.new

  graph.initial_state = state_machine.initial_state.to_s

  state_machine.states.each do |state|
    graph.add_state(state.name.to_s)
  end

  state_machine.events.each do |event|
    event.transitions.each do |transition|
      graph.add_transition(transition.from.to_s, transition.to.to_s, event.name.to_s)
    end
  end

  graph.detect_final_states!

  graph
end