module Sequel::Plugins::Audited::InstanceMethods
Public Instance Methods
blame()
click to toggle source
Returns who put the post into its current state.
post.blame # => 'joeblogs' post.last_audited_by # => 'joeblogs'
Note! returns 'not audited' if there's no audited version (new unsaved record)
# File lib/sequel/plugins/audited.rb, line 231 def blame v = versions.last unless versions.empty? v ? v.modifier : 'not audited' end
Also aliased as: last_audited_by
last_audited_at()
click to toggle source
Returns who put the post into its current state.
post.last_audited_at # => '2015-12-19 @ 08:24:45' post.last_audited_on # => 'joeblogs'
Note! returns 'not audited' if there's no audited version (new unsaved record)
# File lib/sequel/plugins/audited.rb, line 245 def last_audited_at v = versions.last unless versions.empty? v ? v.created_at : 'not audited' end
Also aliased as: last_audited_on
Private Instance Methods
add_audited(event)
click to toggle source
# File lib/sequel/plugins/audited.rb, line 266 def add_audited(event) changed = audited_values(event) unless changed.blank? add_version( event: event, changed: changed ) end end
after_create()
click to toggle source
CALLBACKS ###
Calls superclass method
# File lib/sequel/plugins/audited.rb, line 278 def after_create super add_audited(Sequel::Audited::CREATE) end
after_destroy()
click to toggle source
Calls superclass method
# File lib/sequel/plugins/audited.rb, line 288 def after_destroy super add_audited(Sequel::Audited::DESTROY) end
after_update()
click to toggle source
Calls superclass method
# File lib/sequel/plugins/audited.rb, line 283 def after_update super add_audited(Sequel::Audited::UPDATE) end
audited_values(event)
click to toggle source
extract audited values only
# File lib/sequel/plugins/audited.rb, line 254 def audited_values(event) vals = case event when Sequel::Audited::CREATE self.values when Sequel::Audited::UPDATE (column_changes.empty? ? previous_changes : column_changes) when Sequel::Audited::DESTROY self.values end vals.except(*model.audited_default_ignored_columns) end