Commit 6d3b35e0 authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

avoid generating iv name each time in accessors

parent d657e26d
......@@ -2,14 +2,16 @@ class Module
# 15.2.2.4.13
def attr_reader(*names)
names.each{|name|
define_method(name){self.instance_variable_get('@'+name.to_s)}
name2 = ('@'+name.to_s).intern
define_method(name){self.instance_variable_get(name2)}
}
end
# 15.2.2.4.14
def attr_writer(*names)
names.each{|name|
aset = (name.to_s+"=").intern
define_method(aset){|v|self.instance_variable_set('@'+name.to_s,v)}
name2 = ('@'+name.to_s).intern
name = (name.to_s+"=").intern
define_method(name){|v|self.instance_variable_set(name2,v)}
}
end
# 15.2.2.4.12
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment