I am trying to use ruby refinements to impose rail hooks.
I want to avoid monkey patches. When the monkey patch will work as such
ActiveRecord::Base.class_eval do after_find do # do something with my_method end def my_method # something useful end end
I got the class way by doing something like this:
module ActiveRecordRefinements refine ActiveRecord::Base.singleton_class do def my_method #something cool end end end
But I can not start the hook. I tried using self.used(klass) but didn't seem to be able to get the syntax correctly.
Any help is appreciated.
Thanks.
ruby ruby-on-rails refinements
Max
source share