Class: LevelUp::FlowchartsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/level_up/flowcharts_controller.rb

Instance Method Summary collapse

Instance Method Details

#graphvizObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/level_up/flowcharts_controller.rb', line 24

def graphviz
  job_type = params[:id]
  job_class = job_type.camelize.safe_constantize

  if job_class
    builder = GraphBuilder.new(job_class)
    graph = builder.graph
    graph.output(:svg => "#{Rails.root}/tmp/#{job_type}.svg")
    send_data(File.open("#{Rails.root}/tmp/#{job_type}.svg").read, filename: "#{job_type}.svg", type: 'image/svg+xml', disposition: 'inline')
  else
    render text: "Job class not found", status: 404
  end
end

#indexObject



9
10
11
# File 'app/controllers/level_up/flowcharts_controller.rb', line 9

def index
  @job_classes = LevelUp::Job.descendants.map { |klass| klass }
end

#showObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/level_up/flowcharts_controller.rb', line 13

def show
  @job_type = params[:id]
  @job_class = @job_type.camelize.safe_constantize
  if @job_class

  else
    flash.now[:alert] = "Job class not found"
  end
end