Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- module DefineHook
- def self.included(other)
- puts "#{other} include #{self}"
- puts "ancestors: #{other.ancestors}"
- end
- def self.extended(other)
- puts "#{other} extend #{self}"
- puts "singleton_class.ancestors: #{other.singleton_class.ancestors}"
- end
- def method_added(name)
- puts "#{self}##{name} added"
- super
- end
- def singleton_method_added(name)
- puts "#{self}.#{name} added"
- super
- end
- end
- module Foo
- class << self; include DefineHook; end
- def foo1; end
- module_function :foo1
- def self.foo2; end
- end
- class Bar
- extend DefineHook
- def bar1; end
- def self.bar2; end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement