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


46
47
48
# File 'app/models/effective/log.rb', line 46

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

#child_logs_datatableObject


66
67
68
# File 'app/models/effective/log.rb', line 66

def child_logs_datatable
  EffectiveLogsDatatable.new(log_id: id)
end

#detailsObject


54
55
56
# File 'app/models/effective/log.rb', line 54

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

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


50
51
52
# File 'app/models/effective/log.rb', line 50

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

#next_logObject


58
59
60
# File 'app/models/effective/log.rb', line 58

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

#prev_logObject


62
63
64
# File 'app/models/effective/log.rb', line 62

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

#to_sObject


42
43
44
# File 'app/models/effective/log.rb', line 42

def to_s
  "Log #{id}"
end