Module: DataMapper::Audited::ClassMethods

Defined in:
lib/dm-audited.rb

Instance Method Summary collapse

Instance Method Details

#is_auditedObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/dm-audited.rb', line 65

def is_audited

  include DataMapper::Audited::InstanceMethods

  before :save do
    @audited_attributes = original_attributes.clone
    @audited_new_record = new?
  end

  before :destroy do
    @audited_attributes = original_attributes.clone
  end

  after :save do
    create_audit(@audited_new_record ? 'create' : 'update')
  end

  after :destroy do
    create_audit('destroy')
  end

end