Dne středa, 2. dubna 2014 20:36:13 UTC+2 Jeremy Evans napsal(a):
>
> Have the create_retry plugin also load the instance_hooks plugin, adding:
>
>      def self.apply(model, opts=OPTS)
>          model.plugin :instance_hooks
>       end
>
>  then instead of doing:
>
>   yield self if block_given?
>
> do:
>
>   before_save_hook(&block) if block
>
> Also, I would change create_retry to be:
>
>   def create_retry(values={}, &block)
>     new(values).save_retry(&block)
>   end
>
> Thanks,
> Jeremy
>

Ok, thanks, it works but only half-way. I cannot reference the user 
throught the block pipes because it is not being passed:

        def run_before_instance_hooks(hook)
          instance_hooks(hook).each{|b| return false if b.call == false}
        end

If I change it to this, it works (not sure I broke something):

        def run_before_instance_hooks(hook)
          instance_hooks(hook).each{|b| return false if b.call(self) == 
false}
        end

I *can* reference the user2 name in the block (and it works), but not so in 
the create_retry method.
I updated the gist https://gist.github.com/ollie/9936087 plugin, spec and 
readme backtrace.

Thanks, Ollie

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to