Module: SolidEvents::Labeler

Defined in:
lib/solid_events/labeler.rb

Class Method Summary collapse

Class Method Details

.action_to_verb(action, status) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/solid_events/labeler.rb', line 13

def action_to_verb(action, status)
  return "created" if action == "create" && status.between?(200, 299)
  return "updated" if action == "update" && status.between?(200, 299)
  return "ended" if action == "destroy" && status.between?(200, 399)

  action
end

.controller_action(controller_name:, action_name:, status:) ⇒ Object



7
8
9
10
11
# File 'lib/solid_events/labeler.rb', line 7

def controller_action(controller_name:, action_name:, status:)
  base = controller_name.to_s.sub(/Controller\z/, "").underscore.singularize
  verb = action_to_verb(action_name.to_s, status.to_i)
  "#{base}.#{verb}"
end