brototype 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/brototype/bromise.rb +6 -3
- data/lib/brototype/version.rb +1 -1
- data/spec/brototype_spec.rb +18 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10be00fb9ae62ee2814618fd65a90fab2a982008
|
4
|
+
data.tar.gz: c4e9d82dc502c8aa699775cff6aa9acc0fc4a26b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32b1b51812443de5c4a483138b54b26c95958e227a9a67cd98b201967ece0ba76aed3ad3b7087b934ad9823373def6fa52a9f588a2d02b8d52f59ce116d6c390
|
7
|
+
data.tar.gz: ede30c6eecacbfcaa1c643c4194dad91400fa7ef4c54c3ef43837c5e274cca2933d00aff30f2036e6cc17e88735e71a10797d6126a38c9adf9b06eeb10851ef8
|
data/lib/brototype/bromise.rb
CHANGED
@@ -10,11 +10,14 @@ module Brototype
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def but_when_i_do(callback=nil)
|
13
|
+
return_value = nil
|
13
14
|
if @object.respond_to? @method
|
14
15
|
return_value = @object.send(@method)
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
else
|
17
|
+
return_value = Bro.new(@object).i_can_haz @method
|
18
|
+
end
|
19
|
+
if return_value
|
20
|
+
(callback || (lambda {|x|1})).call return_value
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
data/lib/brototype/version.rb
CHANGED
data/spec/brototype_spec.rb
CHANGED
@@ -55,7 +55,7 @@ describe Brototype do
|
|
55
55
|
success = false
|
56
56
|
@anon_bro = Brototype::Bro.new(@anon_class)
|
57
57
|
|
58
|
-
@anon_bro.i_dont_always('bar').but_when_i_do(lambda { |x|
|
58
|
+
@anon_bro.i_dont_always('foo.bar').but_when_i_do(lambda { |x|
|
59
59
|
success = true
|
60
60
|
})
|
61
61
|
expect(success).to be false
|
@@ -85,6 +85,23 @@ describe Brototype do
|
|
85
85
|
})
|
86
86
|
expect(param).to be 91
|
87
87
|
end
|
88
|
+
|
89
|
+
it 'should work with hash keys too' do
|
90
|
+
success = false
|
91
|
+
result = nil
|
92
|
+
|
93
|
+
@bro.i_dont_always('foo.baz').but_when_i_do(lambda { |x|
|
94
|
+
success = true
|
95
|
+
})
|
96
|
+
expect(success).to be false
|
97
|
+
|
98
|
+
@bro.i_dont_always('foo.bar').but_when_i_do(lambda { |x|
|
99
|
+
success = true
|
100
|
+
result = x
|
101
|
+
})
|
102
|
+
expect(result).to eq("baz")
|
103
|
+
|
104
|
+
end
|
88
105
|
|
89
106
|
end
|
90
107
|
|