Module: Signalman::EventsHelper

Defined in:
app/helpers/signalman/events_helper.rb

Instance Method Summary collapse

Instance Method Details

#badge_for_request_duration(duration, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'app/helpers/signalman/events_helper.rb', line 8

def badge_for_request_duration(duration, &block)
  if duration <= 200
    tag.span "#{duration.round}ms", class: "bg-gray-100 text-gray-800 px-2 py-1 rounded text-xs"
  elsif duration <= 500
    tag.span "#{duration.round}ms", class: "bg-yellow-100 text-yellow-800 px-2 py-1 rounded text-xs"
  else
    tag.span "#{duration.round}ms", class: "bg-red-100 text-red-800 rounded px-2 py-1 text-xs"
  end
end

#signalman_path_for(event) ⇒ Object



3
4
5
6
# File 'app/helpers/signalman/events_helper.rb', line 3

def signalman_path_for(event)
  block = Signalman.events.find{ |key, _| key.match? event.name }.last[:path]
  instance_exec event, &block
end