Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Including multiple modules into class
$ irb
irb(main):001:0> module Mod1
irb(main):002:1> def self.included base
irb(main):003:2> puts 'included Mod1'
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> module Mod2
irb(main):007:1> def self.included base
irb(main):008:2> puts 'included Mod2'
irb(main):009:2> end
irb(main):010:1> end
=> nil
irb(main):011:0> class Cls1
irb(main):012:1> include Mod1, Mod2
irb(main):013:1> end
included Mod2
included Mod1
=> Cls1
irb(main):014:0> class Cls2
irb(main):015:1> include Mod1
irb(main):016:1> include Mod2
irb(main):017:1> end
included Mod1
included Mod2
=> Cls2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.