On Apr 9, 2010, at 4:26 AM, Joao Carlos wrote:
I just came across a situation where it would be extremely handy to
have a method that returns the receiver.
Imagine the following example:
filter = %w(with_votes without_votes).include?(params[:filter]) ?
params[:filter].to_sym : :self
Idea.published.send(filter).all
The implementation would be pretty simple:
class Object
def self
self
end
end
Should this be a part of Rails?
(somehow managed to forget to hit send on this one yesterday. sigh.)
Smalltalk has a method Object#yourself which does just that. The most
common use case is with cascaded message sends, but Ruby doesn't have
those. I've wanted #yourself in Ruby now and then too. Since Matz
was very familiar with Smalltalk when he created Ruby I assume he
didn't think it was necessary, but it's one of the questions I always
want to ask him but forget to when I get the chance.
--
Josh Susser
http://blog.hasmanythrough.com
--
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Core" group.
To post to this group, send email to rubyonrails-c...@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.