aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-11-28 16:55:48 +0100
committerJosé Valim <jose.valim@gmail.com>2010-11-28 16:55:53 +0100
commite444439fe28f873c783a4b99b1c9f29a7405dd0d (patch)
tree75ac578b9a756cabf8af1d08e969d3623f440610 /activerecord/lib/active_record/persistence.rb
parent31906eecdf7bffc2203379c5d40f1bb77fb35858 (diff)
downloadrails-e444439fe28f873c783a4b99b1c9f29a7405dd0d.tar.gz
rails-e444439fe28f873c783a4b99b1c9f29a7405dd0d.tar.bz2
rails-e444439fe28f873c783a4b99b1c9f29a7405dd0d.zip
Partialy revert f1c13b0dd7b22b5f6289ca1a09f1d7a8c7c8584b
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 594a2214bb..75dba0206d 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -4,7 +4,7 @@ module ActiveRecord
# Returns true if this object hasn't been saved yet -- that is, a record
# for the object doesn't exist in the data store yet; otherwise, returns false.
def new_record?
- !@persisted
+ @new_record
end
# Returns true if this object has been destroyed, otherwise returns false.
@@ -15,7 +15,7 @@ module ActiveRecord
# Returns if the record is persisted, i.e. it's not a new record and it was
# not destroyed.
def persisted?
- @persisted && !destroyed?
+ !(new_record? || destroyed?)
end
# Saves the model.
@@ -94,7 +94,7 @@ module ActiveRecord
became = klass.new
became.instance_variable_set("@attributes", @attributes)
became.instance_variable_set("@attributes_cache", @attributes_cache)
- became.instance_variable_set("@persisted", persisted?)
+ became.instance_variable_set("@new_record", new_record?)
became.instance_variable_set("@destroyed", destroyed?)
became.type = klass.name unless self.class.descends_from_active_record?
became
@@ -241,7 +241,7 @@ module ActiveRecord
private
def create_or_update
raise ReadOnlyRecord if readonly?
- result = persisted? ? update : create
+ result = new_record? ? create : update
result != false
end
@@ -270,7 +270,7 @@ module ActiveRecord
self.id ||= new_id
- @persisted = true
+ @new_record = false
id
end