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