Namespace

Audited::Audit

Public Class Methods

included(klass) click to toggle source
# File lib/audited/audit.rb, line 3
def self.included(klass)
  klass.extend(ClassMethods)
  klass.setup_audit
end

Public Instance Methods

new_attributes() click to toggle source

Returns a hash of the changed attributes with the new values

# File lib/audited/audit.rb, line 75
def new_attributes
  (audited_changes || {}).inject({}.with_indifferent_access) do |attrs,(attr,values)|
    attrs[attr] = values.is_a?(Array) ? values.last : values
    attrs
  end
end
old_attributes() click to toggle source

Returns a hash of the changed attributes with the old values

# File lib/audited/audit.rb, line 83
def old_attributes
  (audited_changes || {}).inject({}.with_indifferent_access) do |attrs,(attr,values)|
    attrs[attr] = Array(values).first

    attrs
  end
end
revision() click to toggle source

Return an instance of what the object looked like at this revision. If the object has been destroyed, this will be a new record.

# File lib/audited/audit.rb, line 67
def revision
  clazz = auditable_type.constantize
  (clazz.find_by_id(auditable_id) || clazz.new).tap do |m|
    self.class.assign_revision_attributes(m, self.class.reconstruct_attributes(ancestors).merge({ :version => version }))
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.