Created
July 1, 2012 18:53
-
-
Save apeiros/3029233 to your computer and use it in GitHub Desktop.
Failure of `extend self`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ostruct' | |
module Normalizer | |
extend self | |
def trim(str) | |
str.strip | |
end | |
end | |
obj = OpenStruct.new | |
obj.extend Normalizer | |
obj.trim = 'You must trim 5 spaces!' | |
obj.trim # fails, because it's hitting Normalizer#trim, wouldn't happen with module_function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BOOM! It does work, you are attempting to mix this the wrong way.