Class: EventSender

Inherits:
Object
  • Object
show all
Defined in:
app/models/event_sender.rb

Overview

rubocop:todo Style/Documentation

Class Method Summary collapse

Class Method Details

.send_fail_event(request, reason, comment, batch_id) ⇒ Object


3
4
5
# File 'app/models/event_sender.rb', line 3

def self.send_fail_event(request, reason, comment, batch_id)
  send_state_event('fail', request, reason, comment, batch_id)
end

.send_pass_event(request, reason, comment, batch_id) ⇒ Object


7
8
9
# File 'app/models/event_sender.rb', line 7

def self.send_pass_event(request, reason, comment, batch_id)
  send_state_event('pass', request, reason, comment, batch_id)
end

.send_pick_event(well, purpose_name, message, options = nil) ⇒ Object


28
29
30
31
32
33
34
35
36
# File 'app/models/event_sender.rb', line 28

def self.send_pick_event(well, purpose_name, message, options = nil)
  hash = {
    eventful: well,
    family: PlatesHelper.event_family_for_pick(purpose_name),
    message: message,
    content: Date.today.to_s
  }
  create!(hash.merge(options || {}))
end

.send_request_update(request, family, message, options = nil) ⇒ Object


23
24
25
26
# File 'app/models/event_sender.rb', line 23

def self.send_request_update(request, family, message, options = nil)
  hash = { eventful: request, family: family, message: message }
  create!(hash.merge(options || {}))
end

.send_state_event(state, request, reason, comment, batch_id, user = nil) ⇒ Object

rubocop:todo Metrics/ParameterLists


11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/event_sender.rb', line 11

def self.send_state_event(state, request, reason, comment, batch_id, user = nil) # rubocop:todo Metrics/ParameterLists
  hash = {
    eventful: request,
    family: state,
    content: reason,
    message: comment,
    identifier: batch_id,
    created_by: user
  }
  create!(hash)
end