Class: Effective::Log

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/log.rb

Instance Method Summary collapse

Instance Method Details

#associated_to_s=(value) ⇒ Object



44
45
46
# File 'app/models/effective/log.rb', line 44

def associated_to_s=(value)
  super(value.to_s[0...255].presence) # Take only first 255 characters
end

#child_logs_datatableObject



64
65
66
# File 'app/models/effective/log.rb', line 64

def child_logs_datatable
  EffectiveLogsDatatable.new(log_id: id)
end

#detailsObject



52
53
54
# File 'app/models/effective/log.rb', line 52

def details
  self[:details] || {}
end

#log(message, status = EffectiveLogging.statuses.first, options = {}) ⇒ Object



48
49
50
# File 'app/models/effective/log.rb', line 48

def log(message, status = EffectiveLogging.statuses.first, options = {})
  EffectiveLogger.log(message, status, (options || {}).merge(parent: self))
end

#next_logObject



56
57
58
# File 'app/models/effective/log.rb', line 56

def next_log
  Log.order(id: :asc).where(parent_id: parent_id).where('id > ?', id).first
end

#prev_logObject



60
61
62
# File 'app/models/effective/log.rb', line 60

def prev_log
  Log.order(id: :desc).where(parent_id: parent_id).where('id < ?', id).first
end

#to_sObject



40
41
42
# File 'app/models/effective/log.rb', line 40

def to_s
  "Log #{id}"
end