Module: Model::Err

Extended by:
ActiveSupport::Concern
Included in:
Com::Err
Defined in:
app/models/com/model/err.rb

Instance Method Summary collapse

Instance Method Details

#process_jobObject



40
41
42
# File 'app/models/com/model/err.rb', line 40

def process_job
  ErrJob.perform_later(self)
end

#record(payload) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/models/com/model/err.rb', line 44

def record(payload)
  self.path = payload[:path]
  self.controller_name = payload[:controller]
  self.action_name = payload[:action]
  self.exception = payload[:exception].join("\r\n")[0..self.class.columns_limit['exception']]
  self.exception_object = payload[:exception_object].class.to_s
  self.exception_backtrace = payload[:exception_object].backtrace
  self.params = self.class.filter_params(payload[:params])

  raw_headers = payload.fetch(:headers, {})
  self.headers = self.class.request_headers(raw_headers)
  self.ip = raw_headers['action_dispatch.remote_ip'].to_s
  self.cookie = raw_headers['rack.request.cookie_hash']
  self.session = raw_headers['rack.session'].to_h
end

#record!(payload) ⇒ Object



60
61
62
63
64
# File 'app/models/com/model/err.rb', line 60

def record!(payload)
  record(payload)
  save
  self
end

#send_messageObject



23
24
25
# File 'app/models/com/model/err.rb', line 23

def send_message
  RailsCom.config.notify_bot.constantize.new(self).send_message
end

#user_infoObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/com/model/err.rb', line 27

def 
  token = session.dig('auth_token') || headers.dig('AUTH_TOKEN')
  return {} unless defined? Auth::AuthorizedToken
  at = Auth::AuthorizedToken.find_by token: token
  if at&.user
    at.user.as_json(only: [:id, :name], methods: [:account_identities])
  elsif at&.
    at..as_json(only: [:id, :identity])
  else
    {}
  end
end