Skip to content

Commit

Permalink
cleanup deprecated comments, and map if_changed fields up front one time
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Sullivan committed Sep 25, 2008
1 parent 5fcb7ec commit df4e0f9
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/acts_as_versioned.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,7 @@ module ClassMethods
# end
#
# * <tt>if_changed</tt> - Simple way of specifying attributes that are required to be changed before saving a model. This takes
# either a symbol or array of symbols. WARNING - This will attempt to overwrite any attribute setters you may have.
# Use this instead if you want to write your own attribute setters (and ignore if_changed):
#
# def name=(new_name)
# write_changed_attribute :name, new_name
# end
# either a symbol or array of symbols.
#
# * <tt>extend</tt> - Lets you specify a module to be mixed in both the original and versioned models. You can also just pass a block
# to create an anonymous mixin:
Expand Down Expand Up @@ -220,7 +215,7 @@ def latest
unless options[:if_changed].nil?
self.track_altered_attributes = true
options[:if_changed] = [options[:if_changed]] unless options[:if_changed].is_a?(Array)
self.version_if_changed = options[:if_changed]
self.version_if_changed = options[:if_changed].map(&:to_s)
end
include options[:extend] if options[:extend].is_a?(Module)
Expand Down Expand Up @@ -327,7 +322,7 @@ def save_without_revision!
end

def altered?
track_altered_attributes ? (version_if_changed.map(&:to_s) - changed).length < version_if_changed.length : changed?
track_altered_attributes ? (version_if_changed - changed).length < version_if_changed.length : changed?
end

# Clones a model. Used when saving a new version or reverting a model's version.
Expand Down

0 comments on commit df4e0f9

Please sign in to comment.