7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/datashift_journey/api/v1/states_controller.rb', line 7
def index
state_paths = []
DatashiftJourney.journey_plan_class.new.state_paths.each_with_index do |s, i|
state_paths << {
index: i, events: s.events, from_name: s.from_name, to_name: s.to_name
}
end
states = DatashiftJourney.journey_plan_class.state_machine.states.collect do |s|
{
name: s.name, value: s.value, initial: s.initial, final: s.final?
}
end
events = DatashiftJourney.journey_plan_class.state_machine.events.collect do |e|
{
name: e.name,
qualified_name: e.qualified_name,
human_name: e.human_name,
branches: e.branches,
known_states: e.known_states,
transitions: e.branches.map do |branch|
branch.state_requirements.map do |state_requirement|
{state_requirement: state_requirement, from: state_requirement[:from].class, to: state_requirement[:to]}
end
end
}
end
render json: { data:
{
states: states, state_paths: state_paths, events: events
}
}
end
|