1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

cleaning up many more warnings in activerecord [#4180 state:resolved]

Signed-off-by: wycats <wycats@gmail.com>
This commit is contained in:
Aaron Patterson 2010-03-14 17:43:59 -07:00 committed by wycats
parent 96bc6bcfee
commit 5de3698e2b
4 changed files with 17 additions and 3 deletions

View file

@ -1042,6 +1042,9 @@ module ActiveRecord #:nodoc:
object.instance_variable_set(:'@attributes', record)
object.instance_variable_set(:'@attributes_cache', {})
object.instance_variable_set(:@new_record, false)
object.instance_variable_set(:@readonly, false)
object.instance_variable_set(:@destroyed, false)
object.instance_variable_set(:@marked_for_destruction, false)
object.send(:_run_find_callbacks)
object.send(:_run_initialize_callbacks)
@ -1508,6 +1511,9 @@ module ActiveRecord #:nodoc:
@attributes_cache = {}
@new_record = true
@readonly = false
@destroyed = false
@marked_for_destruction = false
ensure_proper_type
if scope = self.class.send(:current_scoped_methods)
@ -1599,12 +1605,12 @@ module ActiveRecord #:nodoc:
# Returns true if this object hasn't been saved yet -- that is, a record for the object doesn't exist yet; otherwise, returns false.
def new_record?
@new_record || false
@new_record
end
# Returns true if this object has been destroyed, otherwise returns false.
def destroyed?
@destroyed || false
@destroyed
end
# Returns if the record is persisted, i.e. it's not a new record and it was not destroyed.

View file

@ -7,6 +7,9 @@ module ActiveRecord
def initialize(method)
@finder = :first
@bang = false
@instantiator = nil
case method.to_s
when /^find_(all_by|last_by|by)_([_a-zA-Z]\w*)$/
@finder = :last if $1 == 'last_by'

View file

@ -315,7 +315,9 @@ module ActiveRecord
end
def announce(message)
text = "#{@version} #{name}: #{message}"
version = defined?(@version) ? @version : nil
text = "#{version} #{name}: #{message}"
length = [0, 75 - text.length].max
write "== %s %s" % [text, "=" * length]
end

View file

@ -18,6 +18,9 @@ module ActiveRecord
@readonly_value = nil
@create_with_value = nil
@implicit_readonly = nil
@limit_value = nil
@offset_value = nil
@loaded = nil
(ASSOCIATION_METHODS + MULTI_VALUE_METHODS).each {|v| instance_variable_set(:"@#{v}_values", [])}
end