Created
April 7, 2011 14:36
-
-
Save LeipeLeon/907873 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
module MyAccessors | |
@@my_accessors = [] | |
def my_accessor var | |
attr_accessor var | |
@@my_accessors << var | |
end | |
def my_attributes | |
@@my_accessors | |
end | |
end | |
class MyClass | |
self.extend( MyAccessors) | |
my_accessor :field1 | |
my_accessor :field2 | |
end | |
class MySecondClass | |
self.extend( MyAccessors) | |
my_accessor :field3 | |
my_accessor :field4 | |
end | |
p MyClass.my_attributes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment