How to prepend classmethods

前端 未结 2 1224
轮回少年
轮回少年 2020-12-08 07:59

This question directly relates to this one. But I tried to break it down to the base problem and I didn\'t want to enter even more text into the other question box. So here

2条回答
  •  猫巷女王i
    2020-12-08 08:42

    A simpler version:

    module Extensions
      def bar
        'Extended Bar!'
      end  
    end
    
    Foo.singleton_class.prepend Extensions
    

提交回复
热议问题