4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/overider.rb', line 4
def overide(sym, &pr)
orig_unbound_method = self.instance_method(sym)
define_method(sym) do |*a, &blk|
orig_self = self
obj = Object.new
obj.define_singleton_method(:overiden) do |*a, &blk|
orig_bound_method = orig_unbound_method.bind(orig_self)
if !!blk then
orig_bound_method.call *a, &blk
else
orig_bound_method.call *a
end
end
if !!blk then
obj.instance_exec(*a, blk, &pr)
else
obj.instance_exec(*a, &pr)
end
end
end
|