Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module M
- def base_constant(constant)
- self.class.const_get(constant)
- end
- def display_constant
- puts "Module M needs to access the #{base_constant(:SOME_CONSTANT)}"
- end
- end
- class A
- SOME_CONSTANT = "Constant from A"
- include M
- end
- class B
- SOME_CONSTANT = "Constant from B"
- include M
- end
- a = A.new
- a.display_constant
- b = B.new
- b.display_constant
Add Comment
Please, Sign In to add comment