Permalink
Browse files

Move initialize_copy method around to let new method / build alias cl…

…oser
  • Loading branch information...
1 parent 36ee580 commit b69fd477e522654f8ae8c1d4ae3a1ee1ce965752 @carlosantoniodasilva carlosantoniodasilva committed Nov 22, 2012
Showing with 8 additions and 8 deletions.
  1. +8 −8 activerecord/lib/active_record/relation.rb
View
16 activerecord/lib/active_record/relation.rb
@@ -31,6 +31,14 @@ def initialize(klass, table, values = {})
@default_scoped = false
end
+ def initialize_copy(other)
+ # This method is a hot spot, so for now, use Hash[] to dup the hash.
+ # https://bugs.ruby-lang.org/issues/7166
+ @values = Hash[@values]
+ @values[:bind] = @values[:bind].dup if @values.key? :bind
+ reset
+ end
+
def insert(values)
primary_key_value = nil
@@ -90,14 +98,6 @@ def new(*args, &block)
scoping { @klass.new(*args, &block) }
end
- def initialize_copy(other)
- # This method is a hot spot, so for now, use Hash[] to dup the hash.
- # https://bugs.ruby-lang.org/issues/7166
- @values = Hash[@values]
- @values[:bind] = @values[:bind].dup if @values.key? :bind
- reset
- end
-
alias build new
# Tries to create a new record with the same scoped attributes

0 comments on commit b69fd47

Please sign in to comment.