Class: Rscratch::ExceptionLog
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Rscratch::ExceptionLog
- Defined in:
- app/models/rscratch/exception_log.rb
Constant Summary collapse
- STATUS =
> Defining statuses
%w(new under_development resolved)
Instance Method Summary collapse
- #last_resolved(exception_id) ⇒ Object
- #log_count(exception_id) ⇒ Object
- #new_log_count(exception_id) ⇒ Object
- #resolve! ⇒ Object
-
#set_attributes_for(exc, request) ⇒ Object
Sets Log instance attributes.
- #start_development! ⇒ Object
Instance Method Details
#last_resolved(exception_id) ⇒ Object
56 57 58 |
# File 'app/models/rscratch/exception_log.rb', line 56 def last_resolved exception_id ExceptionLog.by_exception(exception_id).resolved.last end |
#log_count(exception_id) ⇒ Object
52 53 54 |
# File 'app/models/rscratch/exception_log.rb', line 52 def log_count exception_id ExceptionLog.by_exception(exception_id).count end |
#new_log_count(exception_id) ⇒ Object
60 61 62 63 |
# File 'app/models/rscratch/exception_log.rb', line 60 def new_log_count exception_id _last_resolved = last_resolved exception_id _new_count = _last_resolved.present? ? ExceptionLog.by_exception(exception_id).unresolved_exceptions(_last_resolved.id).count : log_count(exception_id) end |
#resolve! ⇒ Object
36 37 38 |
# File 'app/models/rscratch/exception_log.rb', line 36 def resolve! update_attribute(:status, 'resolved') end |
#set_attributes_for(exc, request) ⇒ Object
Sets Log instance attributes.
41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/rscratch/exception_log.rb', line 41 def set_attributes_for exc, request self.backtrace = exc.backtrace.join("\n"), self.request_url = request.original_url, self.request_method = request.request_method, self.parameters = request.filtered_parameters, self.user_agent = request.user_agent, self.client_ip = request.remote_ip, self.status = "new", self.description = exc.inspect end |
#start_development! ⇒ Object
32 33 34 |
# File 'app/models/rscratch/exception_log.rb', line 32 def start_development! update_attribute(:status, 'under_development') end |