Skip to content

Instantly share code, notes, and snippets.

@mrkcor
Created December 1, 2011 10:42
Show Gist options
  • Save mrkcor/1415722 to your computer and use it in GitHub Desktop.
Save mrkcor/1415722 to your computer and use it in GitHub Desktop.
Example
class Animal
def initialize(species)
@species = species
end
def species
@species
end
end
class Animal
def self.property(name)
define_method(name) do
puts "Animal has a #{name} property"
end
end
property :tail
end
animal = Animal.new("cat")
puts "Animal is a #{animal.species}"
animal.tail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment