ruby - self.included in a module -


i have class brand includes module simpleurlsanitizer. module has class method defined below:

class brand   include simpleurlsanitizer end  module simpleurlsanitizer   def self.included base     base.send :extend, self   end end 

since including module, have access module's instance methods. class method included called when module included in class. base brand class. included method doing? self inside method referring module or brand class? how work?

as you're including simpleurlsanitizer in class, methods of simpleurlsanitizer accessible instance method. default behavior.

the included part making sure that, can access methods class methods.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -