Skip to content

Instantly share code, notes, and snippets.

@cyrilchampier
Created November 27, 2019 14:59
Show Gist options
  • Save cyrilchampier/2ff05ffd1ed276f024c1f6cbff91d668 to your computer and use it in GitHub Desktop.
Save cyrilchampier/2ff05ffd1ed276f024c1f6cbff91d668 to your computer and use it in GitHub Desktop.
extend == singleton include
# extend == include in singleton class
module Mincluded
def toto
puts 'Mincluded#toto'
end
end
module MSingletonIncluded
def toto
puts 'MSingletonIncluded#toto'
end
end
module MExtended
def toto
puts 'MExtended#toto'
end
end
class A
include Mincluded
extend MExtended
class << self
include MSingletonIncluded
end
end
A.ancestors
A.singleton_class.ancestors
A.toto
A.new.toto
def A.new.pouet
puts 'pouet'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment