-
-
Save unixcharles/9495608 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 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