Thursday, January 27, 2011

[Rails] Why use send when you can call the method directly?

I am reading through some code in active_record/relation/query_methods - def build_where (about line 230); and there are a couple of calls to send.  Here's the first one
[@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))]

and here's the second one
attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts)

Why do we use send here when we could just call the method directly?
I mean, why is the first call not just
[@klass.sanitize_sql( other.empty? ? opts : ([opts] + other))]

Puzzled.

William

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate