Skip to content

Instantly share code, notes, and snippets.

@viniciussbs
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save viniciussbs/1a45c2189e9cf7b2484c to your computer and use it in GitHub Desktop.
Save viniciussbs/1a45c2189e9cf7b2484c to your computer and use it in GitHub Desktop.
class Person
attr_reader :attributes # "getter"
def initialize
@attributes = {}
end
def name
@attributes[:name]
end
end
john_doe = Person.new
# #<Person:0x007fa713c56d60 @attributes={}>
john_doe.attributes
# {}
john_doe.attributes[:name] = "John Doe"
# { :name => "John Doe}
john_doe.name
# "John Doe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment