Module: Auditing::Auditor

Included in:
Audit
Defined in:
lib/auditing/auditor.rb

Instance Method Summary collapse

Instance Method Details

#new_valueObject



13
14
15
16
# File 'lib/auditing/auditor.rb', line 13

def new_value
  return nil unless read_attribute(:new_value)
  Marshal.load( ActiveSupport::Base64.decode64( read_attribute(:new_value) ) )
end

#old_valueObject



8
9
10
11
# File 'lib/auditing/auditor.rb', line 8

def old_value
  return nil unless read_attribute(:old_value)
  Marshal.load( ActiveSupport::Base64.decode64( read_attribute(:old_value) ) )
end

#reversable?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/auditing/auditor.rb', line 4

def reversable?
  undoable?
end

#rollbackObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/auditing/auditor.rb', line 18

def rollback
  return unless reversable?
  
  if association.blank?
    auditable.update_attribute(field_name.to_sym, old_value)
  else
    association.class.find(association_id).update_attribute(field_name.to_sym, old_value)
  end

end