Ruby on Rails Monday, September 6, 2010

inside Rails source, at
http://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/query_methods.rb
I found a lot of calls to:


relation = clone


I can understand where id the "relation" call, but... how about "clone"
?
Perhaps "clone" comes from Ruby1.9-Kernel, but I am not sure.
And github color it in blue, like a class...weird...


def where(opts, *rest)
relation = clone

if opts.present? && value = build_where(opts, rest)
relation.where_values += Array.wrap(value)
end

relation
end


Can somebody explain this "clone" ? Where it come from ?
Thanks
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment