-
-
Save banister/792873 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 Person | |
def add_accessor(accessor_name) | |
class << self; self; end.class_eval do | |
attr_accessor accessor_name | |
end | |
end | |
end | |
person = Person.new | |
Person.add_accessor :name | |
Person.add_accessor :gender | |
person.name = "Peter Cooper" | |
person.gender = "male" | |
puts "#{person.name} is #{person.gender}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment