Module: CollectiveIdea::Acts::Audited::InstanceMethods
- Defined in:
- lib/acts_as_audited.rb
Instance Method Summary collapse
- #audited_attributes ⇒ Object
-
#revision(version) ⇒ Object
Get a specific revision specified by the version number, or
:previous
. - #revision_at(date_or_time) ⇒ Object
-
#revisions(from_version = 1) ⇒ Object
Gets an array of the revisions available.
-
#save_without_auditing ⇒ Object
Temporarily turns off auditing while saving.
-
#without_auditing(&block) ⇒ Object
Executes the block with the auditing callbacks disabled.
Instance Method Details
#audited_attributes ⇒ Object
207 208 209 |
# File 'lib/acts_as_audited.rb', line 207 def audited_attributes attributes.except(*non_audited_columns) end |
#revision(version) ⇒ Object
Get a specific revision specified by the version number, or :previous
198 199 200 |
# File 'lib/acts_as_audited.rb', line 198 def revision(version) revision_with Audit.reconstruct_attributes(audits_to(version)) end |
#revision_at(date_or_time) ⇒ Object
202 203 204 205 |
# File 'lib/acts_as_audited.rb', line 202 def revision_at(date_or_time) audits = self.audits.find(:all, :conditions => ["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
190 191 192 193 194 195 |
# File 'lib/acts_as_audited.rb', line 190 def revisions(from_version = 1) audits = self.audits.find(:all, :conditions => ['version >= ?', from_version]) return [] if audits.empty? revision = self.audits.find_by_version(from_version).revision Audit.reconstruct_attributes(audits) {|attrs| revision.revision_with(attrs) } end |
#save_without_auditing ⇒ Object
Temporarily turns off auditing while saving.
169 170 171 |
# File 'lib/acts_as_audited.rb', line 169 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
179 180 181 |
# File 'lib/acts_as_audited.rb', line 179 def without_auditing(&block) self.class.without_auditing(&block) end |