Skip to content

Commit

Permalink
cleaning up many more warnings in activerecord [#4180 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information
tenderlove authored and wycats committed Mar 15, 2010
1 parent 96bc6bc commit 5de3698
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
10 changes: 8 additions & 2 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -1042,6 +1042,9 @@ def instantiate(record)
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)
Expand Down Expand Up @@ -1508,6 +1511,9 @@ def initialize(attributes = nil)
@attributes_cache = {}
@new_record = true
@readonly = false
@destroyed = false
@marked_for_destruction = false

ensure_proper_type

if scope = self.class.send(:current_scoped_methods)
Expand Down Expand Up @@ -1599,12 +1605,12 @@ def quoted_id #: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.
Expand Down
3 changes: 3 additions & 0 deletions activerecord/lib/active_record/dynamic_finder_match.rb
Expand Up @@ -7,6 +7,9 @@ def self.match(method)

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'
Expand Down
4 changes: 3 additions & 1 deletion activerecord/lib/active_record/migration.rb
Expand Up @@ -315,7 +315,9 @@ def write(text="")
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
Expand Down
3 changes: 3 additions & 0 deletions activerecord/lib/active_record/relation.rb
Expand Up @@ -18,6 +18,9 @@ def initialize(klass, table)
@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
Expand Down

0 comments on commit 5de3698

Please sign in to comment.