Initializing instance variables in Mixins

后端 未结 4 892
情话喂你
情话喂你 2021-02-05 21:41

Is there any clean way to initialize instance variables in a Module intended to be used as Mixin? For example, I have the following:

module Example

  def on(..         


        
4条回答
  •  孤独总比滥情好
    2021-02-05 22:22

    modules provides hooks, as Module#included. I suggest you check out ruby doc on the topic, or use ActiveSupport::Concern, which provides some helpers on modules.

提交回复
热议问题