Skip to content

Instantly share code, notes, and snippets.

@unixcharles
Forked from byroot/wtf.rb
Created March 11, 2014 21:36
Show Gist options
  • Save unixcharles/9495608 to your computer and use it in GitHub Desktop.
Save unixcharles/9495608 to your computer and use it in GitHub Desktop.
class Foo
def self.define_attribute(name)
class_eval %{
def #{name}(*args)
attribute(#{name.inspect}, *args)
end
}
end
define_attribute :bar
def attribute(name)
p name
end
end
begin
p Foo.new.bar 100
rescue => e
puts e
end
p Foo.new.bar
begin
p Foo.new.bar 100
rescue => e
puts e
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment