Skip to content

Instantly share code, notes, and snippets.

@shepmaster
Created October 2, 2010 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shepmaster/607709 to your computer and use it in GitHub Desktop.
Save shepmaster/607709 to your computer and use it in GitHub Desktop.
class << Object
def my_aa(sym)
define_method(sym) do
instance_variable_get("@#{sym}")
end
define_method("#{sym}=") do |v|
instance_variable_set("@#{sym}", v)
end
end
end
class Foo
my_aa :alpha
end
a = Foo.new
a.alpha = "cow"
puts a.alpha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment