Skip to content

Instantly share code, notes, and snippets.

@LeipeLeon
Created April 7, 2011 14:36
Show Gist options
  • Save LeipeLeon/907873 to your computer and use it in GitHub Desktop.
Save LeipeLeon/907873 to your computer and use it in GitHub Desktop.
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