Skip to content

Instantly share code, notes, and snippets.

@marioaquino
Created March 18, 2013 02:16
Show Gist options
  • Save marioaquino/5184545 to your computer and use it in GitHub Desktop.
Save marioaquino/5184545 to your computer and use it in GitHub Desktop.
Polite Ruby immutability
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