0
@@ -137,7 +137,7 @@ module ActiveRecord #:nodoc:
0
options[:if_changed] = [options[:if_changed]] unless options[:if_changed].is_a?(Array)
0
options[:if_changed].each do |attr_name|
0
define_method("#{attr_name}=") do |value|
0
- (self.changed_attributes ||= []) << attr_name.to_s unless self.
dirty?(attr_name) or self.send(attr_name) == value
0
+ (self.changed_attributes ||= []) << attr_name.to_s unless self.
changed?(attr_name) or self.send(attr_name) == value
0
write_attribute(attr_name.to_s, value)
0
@@ -234,14 +234,17 @@ module ActiveRecord #:nodoc:
0
self.attributes.keys.select { |k| !self.class.non_versioned_fields.include?(k) }
0
- # If called with no parameters, gets whether the current model is dirty and needs to be versioned.
0
- # If called with a single parameter, gets whether the parameter is currently dirty.
0
- def dirty?(attr_name = nil)
0
+ # If called with no parameters, gets whether the current model has changed and needs to be versioned.
0
+ # If called with a single parameter, gets whether the parameter has changed.
0
+ def changed?(attr_name = nil)
0
(!self.class.track_changed_attributes or (changed_attributes and changed_attributes.length > 0)) :
0
(changed_attributes and changed_attributes.include?(attr_name.to_s))
0
+ # keep old dirty? method
0
+ alias_method :dirty?, :changed?
0
# Clones a model. Used when saving a new version or reverting a model's version.
0
def clone_versioned_model(orig_model, new_model)
0
self.versioned_attributes.each do |key|
0
@@ -255,9 +258,9 @@ module ActiveRecord #:nodoc:
0
- # Checks whether a new version shall be saved or not. Calls <tt>version_condition_met?</tt> and <tt>
dirty?</tt>.
0
+ # Checks whether a new version shall be saved or not. Calls <tt>version_condition_met?</tt> and <tt>
changed?</tt>.
0
- version_condition_met? and
dirty?
0
+ version_condition_met? and
changed?
0
# Checks condition set in the :if option to check whether a revision should be created or not. Override this for
0
@@ -285,7 +288,7 @@ module ActiveRecord #:nodoc:
0
connection.select_one("SELECT MAX(version)+1 AS next_version FROM #{self.class.versioned_table_name} WHERE #{self.class.versioned_foreign_key} = #{self.id}")['next_version'] || 1
0
- # clears current
dirty attributes. Called after save.
0
+ # clears current
changed attributes. Called after save.
0
def clear_changed_attributes
0
self.changed_attributes = []
Comments
No one has commented yet.