hooked 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hooked/aspect.rb +4 -0
- data/lib/hooked/version.rb +1 -1
- data/spec/aspect_spec.rb +7 -0
- metadata +3 -3
data/lib/hooked/aspect.rb
CHANGED
@@ -7,6 +7,10 @@ module Hooked
|
|
7
7
|
if (advice && block) || (!advice && !block)
|
8
8
|
raise ArgumentError, "Pass either an advice argument or a block"
|
9
9
|
end
|
10
|
+
|
11
|
+
if Hash === advice
|
12
|
+
advice, dependencies = nil, advice
|
13
|
+
end
|
10
14
|
|
11
15
|
[:before, :after].each {|d| dependencies[d] ||= [] }
|
12
16
|
@type, @advice, @dependencies = type, (advice || block), dependencies
|
data/lib/hooked/version.rb
CHANGED
data/spec/aspect_spec.rb
CHANGED
@@ -25,6 +25,13 @@ describe Hooked::Aspect do
|
|
25
25
|
obj.advice.should == block.to_proc
|
26
26
|
end
|
27
27
|
|
28
|
+
it "still takes a list of dependencies if no advice argument was passed" do
|
29
|
+
deps = {:before => [:foo], :after => [:bar]}
|
30
|
+
obj = Hooked::Aspect.new nil, deps
|
31
|
+
|
32
|
+
obj.dependencies.should == deps
|
33
|
+
end
|
34
|
+
|
28
35
|
it "fails if both a block and the advice argument were passed" do
|
29
36
|
proc do
|
30
37
|
Hooked::Aspect.new nil, stub("advice") do; end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: hooked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Lars Gierth
|
@@ -64,7 +64,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
hash:
|
67
|
+
hash: -167606191
|
68
68
|
segments:
|
69
69
|
- 0
|
70
70
|
version: "0"
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
hash:
|
76
|
+
hash: -167606191
|
77
77
|
segments:
|
78
78
|
- 0
|
79
79
|
version: "0"
|