Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Fuller
- module ClassMethods
- def classy
- puts "a mixed in class method"
- end
- end
- module InstanceMethods
- def insticky
- puts "a mixed in instance method"
- end
- end
- module CommonMethods
- def everywhere
- puts "a mixed in method for both class and instance"
- end
- end
- def self.included(klass)
- klass.extend(ClassMethods)
- klass.extend(CommonMethods)
- klass.send(:include, CommonMethods)
- klass.send(:include, InstanceMethods)
- end
- end
- class MyKlass
- include Fuller
- end
- MyKlass.classy #=> "a mixed in class method"
- MyKlass.new.insticky #=> "a mixed in instance method"
- MyKlass.everywhere #=> "a mixed in method for both class and instance"
- MyKlass.new.everywhere #=> "a mixed in method for both class and instance"
Add Comment
Please, Sign In to add comment