Skip to content

Commit

Permalink
Added #without_revisions! which is a method similar to changeset! but…
Browse files Browse the repository at this point in the history
… it prevents *all* revisions instead of grouping all into one.
  • Loading branch information
Rich Cavanaugh committed Jun 24, 2008
1 parent 6290ad1 commit 08bd0df
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion acts_as_revisable.gemspec
Expand Up @@ -2,7 +2,7 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--main", "README.rdoc"]
s.summary = "acts_as_revisable enables revision tracking, querying, reverting and branching of ActiveRecord models. Inspired by acts_as_versioned."
s.name = "acts_as_revisable"
s.version = "0.9.0"
s.version = "0.9.1"
s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
s.email = "cavanaugh@fatjam.com"
s.has_rdoc = true
Expand Down
18 changes: 16 additions & 2 deletions lib/acts_as_revisable/acts/revisable.rb
Expand Up @@ -176,7 +176,7 @@ def force_revision? #:nodoc:
self.revisable_force_revision || false
end

# Sets whether or not no revision should be created.
# Sets whether or not a revision should be created.
def no_revision!(val=true) #:nodoc:
self.revisable_no_revision = val
end
Expand Down Expand Up @@ -254,7 +254,21 @@ def changeset!(&block)
save!
end
end


def without_revisions!
return if in_revision? || !block_given?

begin
no_revision!
in_revision!
yield
save!
ensure
in_revision!(false)
no_revision!(false)
end
end

# acts_as_revisable's override for ActiveRecord::Base's #save!
def save_with_revisable!(*args) #:nodoc:
self.revisable_new_params ||= args.extract_options!
Expand Down
2 changes: 1 addition & 1 deletion lib/acts_as_revisable/version.rb
Expand Up @@ -3,7 +3,7 @@ module ActsAsRevisable
module VERSION #:nodoc:
MAJOR = 0
MINOR = 9
TINY = 0
TINY = 1

STRING = [MAJOR, MINOR, TINY].join('.')
end
Expand Down

0 comments on commit 08bd0df

Please sign in to comment.