Created
November 22, 2012 01:58
-
-
Save ehaliewicz/4129020 to your computer and use it in GitHub Desktop.
This file contains 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 Class | |
def attr_accessor_with_default(attr_name, val) | |
attr_name = attr_name.to_s | |
self.class_eval("def #{attr_name}; @#{attr_name} = #{val};end") | |
self.class_eval("@#{attr_name} = #{val}") | |
self.class_eval("def #{attr_name}=(val) @#{attr_name} = val end") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment