I have found one alternative, which Method Wrapping, as described 
here: 
http://stackoverflow.com/questions/4470108/when-monkey-patching-a-method-can-you-call-the-overridden-method-from-the-new-i

You can review the implementation 
here: 
https://github.com/algolia/algoliasearch-rails/commit/d462c125e1e878a91b398c7cf8b95e607f50726e#diff-dfaec67e907148ea8211e17340f0f30cR252

On Wednesday, April 29, 2015 at 1:46:01 PM UTC-4, Kenny Meyer wrote:
>
> I would like to add another after/before hook to a model dynamically. The 
> way I am approaching this is as follows:
>
>           class_eval do
>             define_method(:after_validation) do |*args|
>               super(*args)
>               # Do something
>             end
>             define_method(:before_save) do |*args|
>               # Do something
>               super(*args)
>             end
>             define_method(:after_save) do |*args|
>               super(*args)
>               # Do something
>             end
>           end
>
> However, this seems to override other after/before hooks. How can I keep 
> the other hooks?
>

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