Created
March 18, 2013 02:16
-
-
Save marioaquino/5184545 to your computer and use it in GitHub Desktop.
Polite Ruby immutability
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
class Profile | |
def initialize(email) | |
email_val = email.dup.freeze | |
self.class.send :define_method, :email, -> { email_val } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment