Skip to content

Instantly share code, notes, and snippets.

@solnic
Created July 15, 2010 10:26
Show Gist options
  • Select an option

  • Save solnic/476775 to your computer and use it in GitHub Desktop.

Select an option

Save solnic/476775 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
module A
def self.included(base)
base.extend ClassMethods
end
def a_instance_method
puts 'a instance method'
end
module ClassMethods
def a_class_method
puts 'a class method'
end
end
end
module B
def self.included(base)
base.send :include, A
base.extend ClassMethods
end
def b_instance_method
puts 'b instance method'
end
module ClassMethods
def b_class_method
puts 'b class method'
end
end
end
class Bar
include B
end
class Foo < Bar; end
Bar.a_class_method
Bar.new.a_instance_method
Bar.b_class_method
Bar.new.b_instance_method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment