Top Level Namespace

Defined Under Namespace

Modules: StateMachines

Instance Method Summary collapse

Instance Method Details

#initObject

Define where state machine descriptions will be rendered


2
3
4
5
# File 'lib/state_machines/yard/templates/default/class/html/setup.rb', line 2

def init
  super
  sections.place(:state_machine_details).before(:children)
end

#state_machine_detailsObject

Renders state machine details in the main content of the class's documentation


8
9
10
# File 'lib/state_machines/yard/templates/default/class/html/setup.rb', line 8

def state_machine_details
  erb(:state_machines) if state_machines
end

#state_machine_image_path(machine) ⇒ Object

Generates the image path for the given machine's visualization


24
25
26
27
28
# File 'lib/state_machines/yard/templates/default/class/html/setup.rb', line 24

def state_machine_image_path(machine)
  base_path = File.dirname(serializer.serialized_path(object))
  image_name = "#{object.name}_#{machine[:name]}"
  "#{File.join(base_path, image_name)}.png"
end

#state_machinesObject

Gets a list of state machines for this class


13
14
15
16
17
18
19
20
21
# File 'lib/state_machines/yard/templates/default/class/html/setup.rb', line 13

def state_machines
  @state_machines ||= begin
    if state_machines = object['state_machines']
      state_machines.each do |_name, machine|
        serializer.serialize(state_machine_image_path(machine), machine[:image]) if machine[:image]
      end
    end
  end
end