yfactorial-roxy 0.2 → 0.2.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.
- data/lib/roxy/moxie.rb +10 -28
- metadata +2 -2
data/lib/roxy/moxie.rb
CHANGED
|
@@ -24,37 +24,19 @@ module Roxy
|
|
|
24
24
|
options[:to] = original_method
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# If we have a no-arg method we're proxying, or if we're not
|
|
30
|
-
# proxying an existing method at all, we can do a basic def
|
|
31
|
-
# and memoize the proxy
|
|
27
|
+
# Thanks to Jerry for this simplification of my original class_eval approach
|
|
28
|
+
# http://ryandaigle.com/articles/2008/11/10/implement-ruby-proxy-objects-with-roxy/comments/8059#comment-8059
|
|
32
29
|
if !original_method or original_method.arity == 0
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
nil,
|
|
37
|
-
&self.class.roxy_proxy_methods[:#{name}][1])
|
|
38
|
-
end
|
|
39
|
-
EOS
|
|
40
|
-
|
|
41
|
-
# If we have a proxied method with arguments, we need to
|
|
42
|
-
# retain them
|
|
30
|
+
define_method name do
|
|
31
|
+
(@proxy_for ||= {})[name] ||= Proxy.new(self, options, nil, &block)
|
|
32
|
+
end
|
|
43
33
|
else
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
&self.class.roxy_proxy_methods[:#{name}][1])
|
|
49
|
-
end
|
|
50
|
-
EOS
|
|
51
|
-
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def roxy_proxy_methods
|
|
56
|
-
@roxy_proxy_methods ||= {}
|
|
34
|
+
define_method name do |*args|
|
|
35
|
+
Proxy.new(self, options, args, &block)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
57
38
|
end
|
|
39
|
+
|
|
58
40
|
end
|
|
59
41
|
end
|
|
60
42
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yfactorial-roxy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Daigle
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2008-11-
|
|
12
|
+
date: 2008-11-22 00:00:00 -08:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|