Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module X
- def x
- "x"
- end
- module_function :x
- def self.included(base)
- base.class_eval do
- public :x
- end
- end
- end
- class TestDefault
- include X
- end
- puts TestDefault.new.x
- # => x
- module OverwriteX
- include X
- def x
- "#{super}2"
- end
- end
- class TestOverwrite
- include OverwriteX
- end
- puts TestOverwrite.new.x
- # => x
- module DontOverwriteX
- include X
- end
- class TestDontOverwrite
- include DontOverwriteX
- end
- puts TestDontOverwrite.new.x
- # => x
Add Comment
Please, Sign In to add comment