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
140 141 142 |
# File 'lib/acts_as_audited.rb', line 140 def audited_attributes attributes.except(*non_audited_columns) end |
#revision(version) ⇒ Object
Get a specific revision specified by the version number, or :previous
131 132 133 |
# File 'lib/acts_as_audited.rb', line 131 def revision(version) revision_with Audit.reconstruct_attributes(audits_to(version)) end |
#revision_at(date_or_time) ⇒ Object
135 136 137 138 |
# File 'lib/acts_as_audited.rb', line 135 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
123 124 125 126 127 128 |
# File 'lib/acts_as_audited.rb', line 123 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.
102 103 104 |
# File 'lib/acts_as_audited.rb', line 102 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
112 113 114 |
# File 'lib/acts_as_audited.rb', line 112 def without_auditing(&block) self.class.without_auditing(&block) end |