rhook 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rhook.rb +1 -1
- data/rhook.gemspec +1 -1
- data/spec/rhook_minor_spec.rb +33 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/lib/rhook.rb
CHANGED
@@ -71,7 +71,7 @@ module RHook
|
|
71
71
|
|
72
72
|
def call_method(name, method_name, args, block, opt = {})
|
73
73
|
hooks = concat_hooks([], name)
|
74
|
-
hooks.empty? and @obj.__send__(method_name, *args, &block)
|
74
|
+
hooks.empty? and return @obj.__send__(method_name, *args, &block)
|
75
75
|
|
76
76
|
inv = Invocation.new
|
77
77
|
inv.target = @obj
|
data/rhook.gemspec
CHANGED
data/spec/rhook_minor_spec.rb
CHANGED
@@ -10,6 +10,39 @@ describe "rhook (minor specifications / behavior, and bugs)" do
|
|
10
10
|
Target._rhook.unbind_all()
|
11
11
|
end
|
12
12
|
|
13
|
+
# ================================================================
|
14
|
+
describe "invocation" do
|
15
|
+
describe "is proceed by correct order & not rerun." do
|
16
|
+
class Target
|
17
|
+
attr_reader :order_ary
|
18
|
+
def order_call
|
19
|
+
@order_ary = []
|
20
|
+
_rhook.to.order_target
|
21
|
+
end
|
22
|
+
|
23
|
+
def order_target
|
24
|
+
@order_ary << "orig"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
example do
|
29
|
+
t = Target.new
|
30
|
+
|
31
|
+
# [bug] It calls the target method/procedure twice when no hooks are registered.
|
32
|
+
t.order_call
|
33
|
+
t.order_ary.should == ["orig"]
|
34
|
+
|
35
|
+
t._rhook.bind(:order_target) do |inv|
|
36
|
+
t.order_ary << "before_call"
|
37
|
+
inv.call
|
38
|
+
t.order_ary << "after_call"
|
39
|
+
end
|
40
|
+
t.order_call
|
41
|
+
t.order_ary.should == ["before_call", "orig", "after_call"]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
13
46
|
# ================================================================
|
14
47
|
describe "hack" do
|
15
48
|
# ================================================================
|