Method: CycloneLariat::Presenters::Graph#call

Defined in:
lib/cyclone_lariat/presenters/graph.rb

#call(subscriptions) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cyclone_lariat/presenters/graph.rb', line 13

def call(subscriptions)
  return '' if subscriptions.empty?

  resources_set = Set.new

  subscriptions.each do |subscription|
    resources_set << subscription[:topic]
    resources_set << subscription[:endpoint]
  end

  [].tap do |output|
    output << open_graph

    resources_set.each { |resource| output << present_resource(resource) }
    subscriptions.each { |subscription| output << present_subscription(subscription) }

    output << close_graph
  end
end