acts_as_versioned 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ *0.2.1*
2
+
3
+ * (6 Oct 2005) renamed dirty? to changed? to keep it uniform. it was aliased to keep it backwards compatible.
4
+
1
5
  *0.2*
2
6
 
3
7
  * (6 Oct 2005) added find_versions and find_version class methods.
@@ -137,7 +137,7 @@ module ActiveRecord #:nodoc:
137
137
  options[:if_changed] = [options[:if_changed]] unless options[:if_changed].is_a?(Array)
138
138
  options[:if_changed].each do |attr_name|
139
139
  define_method("#{attr_name}=") do |value|
140
- (self.changed_attributes ||= []) << attr_name.to_s unless self.dirty?(attr_name) or self.send(attr_name) == value
140
+ (self.changed_attributes ||= []) << attr_name.to_s unless self.changed?(attr_name) or self.send(attr_name) == value
141
141
  write_attribute(attr_name.to_s, value)
142
142
  end
143
143
  end
@@ -234,14 +234,17 @@ module ActiveRecord #:nodoc:
234
234
  self.attributes.keys.select { |k| !self.class.non_versioned_fields.include?(k) }
235
235
  end
236
236
 
237
- # If called with no parameters, gets whether the current model is dirty and needs to be versioned.
238
- # If called with a single parameter, gets whether the parameter is currently dirty.
239
- def dirty?(attr_name = nil)
237
+ # If called with no parameters, gets whether the current model has changed and needs to be versioned.
238
+ # If called with a single parameter, gets whether the parameter has changed.
239
+ def changed?(attr_name = nil)
240
240
  attr_name.nil? ?
241
241
  (!self.class.track_changed_attributes or (changed_attributes and changed_attributes.length > 0)) :
242
242
  (changed_attributes and changed_attributes.include?(attr_name.to_s))
243
243
  end
244
244
 
245
+ # keep old dirty? method
246
+ alias_method :dirty?, :changed?
247
+
245
248
  # Clones a model. Used when saving a new version or reverting a model's version.
246
249
  def clone_versioned_model(orig_model, new_model)
247
250
  self.versioned_attributes.each do |key|
@@ -255,9 +258,9 @@ module ActiveRecord #:nodoc:
255
258
  end
256
259
  end
257
260
 
258
- # Checks whether a new version shall be saved or not. Calls <tt>version_condition_met?</tt> and <tt>dirty?</tt>.
261
+ # Checks whether a new version shall be saved or not. Calls <tt>version_condition_met?</tt> and <tt>changed?</tt>.
259
262
  def save_version?
260
- version_condition_met? and dirty?
263
+ version_condition_met? and changed?
261
264
  end
262
265
 
263
266
  # Checks condition set in the :if option to check whether a revision should be created or not. Override this for
@@ -285,7 +288,7 @@ module ActiveRecord #:nodoc:
285
288
  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
286
289
  end
287
290
 
288
- # clears current dirty attributes. Called after save.
291
+ # clears current changed attributes. Called after save.
289
292
  def clear_changed_attributes
290
293
  self.changed_attributes = []
291
294
  end
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: acts_as_versioned
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.2"
6
+ version: 0.2.1
7
7
  date: 2005-10-06
8
8
  summary: Simple versioning with active record models
9
9
  require_paths: