Class: Effective::Log
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::Log
- Defined in:
- app/models/effective/log.rb
Instance Attribute Summary collapse
-
#datatable ⇒ Object
These 3 attr_accessors are set on the controller #show actions.
-
#next_log ⇒ Object
Returns the value of attribute next_log.
-
#prev_log ⇒ Object
Returns the value of attribute prev_log.
Instance Method Summary collapse
- #details ⇒ Object
- #log(message, status = EffectiveLogging.statuses.first, options = {}) ⇒ Object
-
#restore_trashable! ⇒ Object
So this is a Trash item When we delete ourselves, we restore this trash item first.
- #to_s ⇒ Object
Instance Attribute Details
#datatable ⇒ Object
These 3 attr_accessors are set on the controller #show actions
6 7 8 |
# File 'app/models/effective/log.rb', line 6 def datatable @datatable end |
#next_log ⇒ Object
Returns the value of attribute next_log.
7 8 9 |
# File 'app/models/effective/log.rb', line 7 def next_log @next_log end |
#prev_log ⇒ Object
Returns the value of attribute prev_log.
8 9 10 |
# File 'app/models/effective/log.rb', line 8 def prev_log @prev_log end |
Instance Method Details
#details ⇒ Object
51 52 53 |
# File 'app/models/effective/log.rb', line 51 def details self[:details] || {} end |
#log(message, status = EffectiveLogging.statuses.first, options = {}) ⇒ Object
47 48 49 |
# File 'app/models/effective/log.rb', line 47 def log(, status = EffectiveLogging.statuses.first, = {}) EffectiveLogger.log(, status, ( || {}).merge({:parent => self})) end |
#restore_trashable! ⇒ Object
So this is a Trash item When we delete ourselves, we restore this trash item first
57 58 59 60 |
# File 'app/models/effective/log.rb', line 57 def restore_trashable! raise 'no attributes to restore from' unless details.kind_of?(Hash) && details[:attributes].present? associated_type.constantize.new(details[:attributes]).save! end |
#to_s ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/models/effective/log.rb', line 38 def to_s case status when EffectiveLogging.trashable_status [associated_type, associated_id].join(' ').presence || 'New Trash item' else "Log #{id}" end end |