On Thursday, April 3, 2014 1:53:32 AM UTC-7, Oldřich Vetešník wrote:
>
> 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
>
Instead of:
before_save_hook(&block) if block
do:
before_save_hook{block.call(self)} if block
That should hopefully fix it.
Thanks,
Jeremy
--
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.