hijacker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.md +1 -2
- data/lib/hijacker/version.rb +1 -1
- data/lib/hijacker.rb +2 -3
- metadata +2 -2
data/Readme.md
CHANGED
@@ -58,8 +58,7 @@ Run this code and, if you look at the server output, you'll see nothing less
|
|
58
58
|
than...
|
59
59
|
|
60
60
|
<a nice timestamp> MyClass (Class) received :new and returned #<MyClass:0x000000874> (MyClass)
|
61
|
-
<a nice timestamp> #<MyClass:0x000000874> (MyClass) received :foo with 3
|
62
|
-
(Fixnum), 4 (Fixnum) and returned 7
|
61
|
+
<a nice timestamp> #<MyClass:0x000000874> (MyClass) received :foo with 3 (Fixnum), 4 (Fixnum) and returned 7
|
63
62
|
|
64
63
|
If you want to un-hijack any object, just call #restore:
|
65
64
|
|
data/lib/hijacker/version.rb
CHANGED
data/lib/hijacker.rb
CHANGED
@@ -40,7 +40,7 @@ module Hijacker
|
|
40
40
|
receiver.class_eval <<EOS
|
41
41
|
def #{met}(*args, &blk)
|
42
42
|
__original_#{met}(*args,&blk).tap do |retval|
|
43
|
-
Hijacker.register :#{met}, args, retval, self
|
43
|
+
Hijacker.register :#{met}, args, retval, self, #{uri.inspect}
|
44
44
|
end
|
45
45
|
end
|
46
46
|
EOS
|
@@ -48,13 +48,12 @@ EOS
|
|
48
48
|
|
49
49
|
receiver = (class << object; self; end)
|
50
50
|
sing_methods.each do |met|
|
51
|
-
puts "Defining #{met}"
|
52
51
|
receiver.send(:alias_method, :"__original_#{met}", :"#{met}")
|
53
52
|
receiver.send(:undef_method, :"#{met}")
|
54
53
|
receiver.class_eval <<EOS
|
55
54
|
def #{met}(*args, &blk)
|
56
55
|
__original_#{met}(*args,&blk).tap do |retval|
|
57
|
-
Hijacker.register :#{met}, args, retval, self
|
56
|
+
Hijacker.register :#{met}, args, retval, self, #{uri.inspect}
|
58
57
|
end
|
59
58
|
end
|
60
59
|
EOS
|