Skip to content

Commit

Permalink
tweak the way #without_revision works so that it doesnt clobber overr…
Browse files Browse the repository at this point in the history
…idden callback methods

git-svn-id: http://svn.techno-weenie.net/projects/plugins/acts_as_versioned@2837 567b1171-46fb-0310-a4c9-b4bef9110e78
  • Loading branch information
technoweenie committed Apr 8, 2007
1 parent c6acfe1 commit 8fa6d3b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/acts_as_versioned.rb
Expand Up @@ -402,11 +402,6 @@ def write_changed_attribute(attr_name, attr_value)
write_attribute(attr_name, attr_value_for_db)
end

private
CALLBACKS.each do |attr_name|
alias_method "orig_#{attr_name}".to_sym, attr_name
end

module ClassMethods
# Finds a specific version of a specific row of this model
def find_version(id, version)
Expand Down Expand Up @@ -476,17 +471,18 @@ def drop_versioned_table
#
def without_revision(&block)
class_eval do
CALLBACKS.each do |attr_name|
CALLBACKS.each do |attr_name|
alias_method "orig_#{attr_name}".to_sym, attr_name
alias_method attr_name, :empty_callback
end
end
result = block.call
block.call
ensure
class_eval do
CALLBACKS.each do |attr_name|
alias_method attr_name, "orig_#{attr_name}".to_sym
end
end
result
end

# Turns off optimistic locking for the duration of the block
Expand Down

0 comments on commit 8fa6d3b

Please sign in to comment.