ToDo:
Windows ¤Ç¤âư¤¤¤¿¡£ ÌäÂêÅÀ¤Þ¤È¤á¡£
(04:16)
˺¤ì¤Ê¤¤¤¦¤Á¤Ë¡£
̵¤·¡¢¥ê¥×¥ì¥¤¸¡Æ¤¡¢»þ¹ïƱ´ü¡¢Íð¿ôÅϤ·¡¢ ¥¯¥í¡¼¥º¥É¥â¥¸¥å¡¼¥ëÅϤ·¡¢¥Ï¡¼¥É¥¦¥§¥¢ÇÛÉÛ¡£
(04:17)
http://d.hatena.ne.jp/rubyca/20060419/1145459336
Î㤨¤Ð¡£
class MethodCallingError < StandardError; end
module CallOnce
def self.included(cname)
set_trace_func proc{|event, file, line, id, binding, klass|
return if cname != klass
return if event !~ /call/
def klass._define_method(id, &p)
define_method(id, p)
end
klass._define_method(id) do
raise "#{id} called twice"
end
}
end
end
class C
def f
p "func"
end
def f2
p "func2"
end
end
c = C.new
c.f
c.f2
c.f
class C
include CallOnce
end
puts "OK, let's forget."
c.f
c.f2
c.f
def klass._define_method ¤¬¤À¤µ¤¤¡£
(19:15)
Ê̤ˤ³¤ì¤Ç¤¤¤¤¤Î¤«¡£
set_trace_func proc{|event, file, line, id, binding, klass|
return if cname != klass
return if event !~ /call/
klass.send(:define_method, id) do
raise "#{id} called twice"
end
}
¤â¤Á¤í¤óÆóÅÙÌÜ¤Ë include ¤µ¤ì¤¿¾ì¹ç¤Î½èÍý¤È¤«¤·¤Æ¤Ê¤¤¤Î¤Ç¡¢ ¤Þ¤¡¤½¤Î¤Ø¤ó¤ÏŬÅö¤Ë¡£
(19:19)
| Á° | 2006ǯ 4·î |
¼¡ | ||||
| Æü | ·î | ²Ð | ¿å | ÌÚ | ¶â | ÅÚ |
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | ||||||
Á´¤Æ¥ê¥ó¥¯¥Õ¥ê¡¼¤Ç¤¹¡£ ¥³¡¼¥ÉÊҤϼ«Í³¤Ë»ÈÍѤ·¤Æ¤¤¤¿¤À¤¤¤Æ¹½¤¤¤Þ¤»¤ó¡£ ¤½¤Î¾¤Î¤â¤Î¤ÏGPL°·¤¤¤Ç¤¢¤ì¤Ð¤¢¤é¤æ¤ë»ÈÍѤ˴ؤ·¤ÆÊ¸¶ç¤Ï¸À¤¤¤Þ¤»¤ó¡£ ¤Ê¤Ë¤«¤¢¤ì¤Ð²¼µ¥á¡¼¥ë¥¢¥É¥ì¥¹¤Ø¡£