Hi guys, I''m curious what the correct syntax is for performing a delayed method call when used in conjunction with the apply method. I think I was on the right track with curry, but couldn''t quite figure it out. Let''s say I have this call: proceed.apply(this, args) And I want to delay that call. If I could just ignore the args, then I could do this: proceed.bind(this).delay(seconds) The solution to the combination of the two is beyond my powers. Thanks for the help. -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
proceed.curry.apply(proceed.bind(this), args).delay(seconds); Now, it''s a bit convoluted, but should work (at least a couple of precarious tests pass). Best, -Nicolas On Jan 21, 2008 8:56 PM, Justin Perkins <justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi guys,I''m curious what the correct syntax is for performing a delayed > method call when used in conjunction with the apply method. I think I was on > the right track with curry, but couldn''t quite figure it out. > > Let''s say I have this call: proceed.apply(this, args) > > And I want to delay that call. If I could just ignore the args, then I could > do this: proceed.bind(this).delay(seconds) > > The solution to the combination of the two is beyond my powers. > > Thanks for the help. > > -justin > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 21, 2008 5:46 PM, Nicolás Sanguinetti <godfoca-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > proceed.curry.apply(proceed.bind(this), args).delay(seconds);Works beautifully. I would not have figured that out. Thank you. -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Nicolás Sanguinetti a écrit :> proceed.curry.apply(proceed.bind(this), args).delay(seconds);OK, binding is final, so you don''t need to apply, for chrissakes: proceed.curry(proceed.bind(this), args).delay(seconds); Should do the trick… (to test though). -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Nicolás Sanguinetti a écrit :> proceed.curry.apply(proceed.bind(this), args).delay(seconds);OK, sorry about my earlier response, that''s replying while just woken up and having a cold for you. You want to basically call a method with prefilled args in a delayed fashion, right? You don''t need curry if you already bind: bind can do it on the fly: proceed.bind(this, arg1, arg2...).delay(seconds); Now that should work just fine. -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 22, 2008 5:45 AM, Christophe Porteneuve <tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> > Nicolás Sanguinetti a écrit : > > proceed.curry.apply(proceed.bind(this), args).delay(seconds); > > OK, sorry about my earlier response, that''s replying while just woken up > and having a cold for you. > > You want to basically call a method with prefilled args in a delayed > fashion, right? You don''t need curry if you already bind: bind can do > it on the fly: > > proceed.bind(this, arg1, arg2...).delay(seconds); > > Now that should work just fine.Yeah, it works, but what happens if the args are in an array? (you got them from the arguments list, for example) :) Anyway, good point, curry isn''t needed proceed.bind.apply(proceed, [this].concat(args)).delay(seconds) Should work. -Nicolas> -- > Christophe Porteneuve aka TDD > tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
To summarize thus far... proceed.curry.apply(proceed.bind(this), args).delay(seconds) // this works and I like it proceed.curry(proceed.bind(this), args).delay(seconds); // this does not pass the arguments correctly proceed.bind(this, arg1, arg2...).delay(seconds); // this requires me to know the arguments I''m passing proceed.bind.apply(proceed, [this].concat(args)).delay(seconds) // this works, but I still like the first solution the best -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---