Module: ActsAsAudited::Auditor::InstanceMethods

Defined in:
lib/acts_as_audited/auditor.rb

Instance Method Summary collapse

Instance Method Details

#audited_attributesObject

List of attributes that are audited.



146
147
148
# File 'lib/acts_as_audited/auditor.rb', line 146

def audited_attributes
  attributes.except(*non_audited_columns)
end

#revision(version) ⇒ Object

Get a specific revision specified by the version number, or :previous



135
136
137
# File 'lib/acts_as_audited/auditor.rb', line 135

def revision(version)
  revision_with Audit.reconstruct_attributes(audits_to(version))
end

#revision_at(date_or_time) ⇒ Object

Find the oldest revision recorded prior to the date/time provided.



140
141
142
143
# File 'lib/acts_as_audited/auditor.rb', line 140

def revision_at(date_or_time)
  audits = self.audits.where("created_at <= ?", date_or_time)
  revision_with Audit.reconstruct_attributes(audits) unless audits.empty?
end

#revisions(from_version = 1) ⇒ Object

Gets an array of the revisions available

user.revisions.each do |revision|
  user.name
  user.version
end


124
125
126
127
128
129
130
131
132
# File 'lib/acts_as_audited/auditor.rb', line 124

def revisions(from_version = 1)
  audits = self.audits.where(['version >= ?', from_version])
  return [] if audits.empty?
  revisions = []
  audits.each do |audit|
    revisions << audit.revision
  end
  revisions
end

#save_without_auditingObject

Temporarily turns off auditing while saving.



103
104
105
# File 'lib/acts_as_audited/auditor.rb', line 103

def save_without_auditing
  without_auditing { save }
end

#without_auditing(&block) ⇒ Object

Executes the block with the auditing callbacks disabled.

@foo.without_auditing do
  @foo.save
end


113
114
115
# File 'lib/acts_as_audited/auditor.rb', line 113

def without_auditing(&block)
  self.class.without_auditing(&block)
end