renee-core 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/renee_core/chaining.rb +15 -22
- data/lib/renee_core/version.rb +1 -1
- metadata +4 -4
data/lib/renee_core/chaining.rb
CHANGED
@@ -13,8 +13,9 @@ module Renee
|
|
13
13
|
module Chaining
|
14
14
|
# @private
|
15
15
|
class ChainingProxy
|
16
|
-
def initialize(target,
|
17
|
-
@target, @
|
16
|
+
def initialize(target, m, args)
|
17
|
+
@target, @calls = target, []
|
18
|
+
@calls << [m, args]
|
18
19
|
end
|
19
20
|
|
20
21
|
def method_missing(m, *args, &blk)
|
@@ -22,20 +23,19 @@ module Renee
|
|
22
23
|
if blk.nil? && @target.class.private_method_defined?(:"#{m}_without_chain")
|
23
24
|
self
|
24
25
|
else
|
26
|
+
inner_args = []
|
25
27
|
ret = nil
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
ret = @target.send(call.at(0), *call.at(1), &callback)
|
34
|
-
end
|
28
|
+
callback = proc do |*callback_args|
|
29
|
+
inner_args.concat(callback_args)
|
30
|
+
if @calls.size == 0
|
31
|
+
return blk.call(*inner_args) if blk
|
32
|
+
else
|
33
|
+
call = @calls.shift
|
34
|
+
ret = @target.send(call.at(0), *call.at(1), &callback)
|
35
35
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
end
|
37
|
+
call = @calls.shift
|
38
|
+
ret = @target.send(call.at(0), *call.at(1), &callback)
|
39
39
|
ret
|
40
40
|
end
|
41
41
|
end
|
@@ -48,9 +48,7 @@ module Renee
|
|
48
48
|
class_eval <<-EOT, __FILE__, __LINE__ + 1
|
49
49
|
alias_method :#{m}_without_chain, :#{m}
|
50
50
|
def #{m}(*args, &blk)
|
51
|
-
|
52
|
-
#{m}_without_chain(*args, &subblk)
|
53
|
-
end
|
51
|
+
blk.nil? ? ChainingProxy.new(self, #{m.inspect}, args) : #{m}_without_chain(*args, &blk)
|
54
52
|
end
|
55
53
|
private :#{m}_without_chain
|
56
54
|
EOT
|
@@ -58,11 +56,6 @@ module Renee
|
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
61
|
-
private
|
62
|
-
def chain(blk, &proxy)
|
63
|
-
blk ? yield(blk) : ChainingProxy.new(self, proxy)
|
64
|
-
end
|
65
|
-
|
66
59
|
def self.included(o)
|
67
60
|
o.extend(ClassMethods)
|
68
61
|
end
|
data/lib/renee_core/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: renee-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Hull
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-10-
|
20
|
+
date: 2011-10-26 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|