On Oct 27, 7:19 pm, TaQ <eustaquioran...@gmail.com>
wrote:> Hi, I made a patch some days ago:
>
> http://rails.lighthouseapp.com/projects/8994/tickets/1253-arrayto_proc
>
> There is some time I''m using this behaviour and would like to know
> what you guys think about. :-)
Is this the method?
def to_proc
Proc.new do |obj,*args|
self.collect {|method| obj.send(method,*args)}
end
end
Seems pretty good. It''s general (not Rails specific) and honestly I
can''t think of a better use for an Array#to_proc.
Not sure I understand how *args fit in there. How can they even be
used?
Hmm... just occurred to me, and I haven''t tried it, but is this
basically equivalent to:
def to_proc
Proc.new do |obj|
self.collect{ |method| method.to_proc[obj] }
end
end
assuming method is always a symbol.
Not that this is a better implementation; I think it demonstrates the
nature of idea well though.
T.
--~--~---------~--~----~------------~-------~--~----~
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-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---