forwardable-extended 2.5.3 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/forwardable/extended.rb +35 -16
- data/lib/forwardable/extended/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a63d4f78c993a050c8b1cc6aa077296fa7acab3
|
4
|
+
data.tar.gz: dbd35851e146d851ed4d3b1f0db85a5bfb432666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4b9c2dc38d4420b791309886c545b35f1fe9b3ad0211365582f678daed1dee9e84416f39c10949ecbc5421cf85f638cd47068d081d8d74ca75ff246fb3e0764
|
7
|
+
data.tar.gz: 0508f825a4a79e5bb26da05da2489646b741cd86dc8ee51cc956b5d1ba1e2901f10ecfc4513048a03244acea35781f7ee2ceb805c1f6a110db80338f4dbc0583
|
data/lib/forwardable/extended.rb
CHANGED
@@ -46,14 +46,14 @@ module Forwardable
|
|
46
46
|
)
|
47
47
|
end
|
48
48
|
|
49
|
-
class_eval <<-STR, __FILE__, __LINE__ - 9
|
49
|
+
class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 9
|
50
50
|
def #{method}#{suffix}(*args)
|
51
51
|
#{wrap}(
|
52
52
|
#{prefix}#{hash}[#{key.inspect}]
|
53
53
|
)
|
54
54
|
|
55
55
|
rescue Exception
|
56
|
-
|
56
|
+
if !Forwardable.debug && $@ && $@.respond_to?(:delete_if)
|
57
57
|
$@.delete_if do |source|
|
58
58
|
source =~ %r"#{Regexp.escape(__FILE__)}"o
|
59
59
|
end
|
@@ -77,14 +77,14 @@ module Forwardable
|
|
77
77
|
)
|
78
78
|
end
|
79
79
|
|
80
|
-
class_eval <<-STR, __FILE__, __LINE__ - 9
|
80
|
+
class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 9
|
81
81
|
def #{alias_.to_s.gsub(/\A@/, "")}#{suffix}
|
82
82
|
#{wrap}(
|
83
83
|
#{prefix}#{ivar}
|
84
84
|
)
|
85
85
|
|
86
86
|
rescue Exception
|
87
|
-
|
87
|
+
if !Forwardable.debug && $@ && $@.respond_to?(:delete_if)
|
88
88
|
$@.delete_if do |source|
|
89
89
|
source =~ %r"#{Regexp.escape(__FILE__)}"o
|
90
90
|
end
|
@@ -99,24 +99,25 @@ module Forwardable
|
|
99
99
|
# Like def_delegator but allows you to send args and do other stuff.
|
100
100
|
# ------------------------------------------------------------------------
|
101
101
|
|
102
|
-
def def_modern_delegator(accessor, method, alias_ = method, args:
|
103
|
-
|
104
|
-
prefix, suffix, wrap = prepare_delegate(**kwd)
|
102
|
+
def def_modern_delegator(accessor, method, alias_ = method, args: \
|
103
|
+
{ :before => [], :after => [] }, **kwd)
|
105
104
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
105
|
+
prefix, suffix, wrap = prepare_delegate(**kwd)
|
106
|
+
args = { :before => args } unless args.is_a?(Hash)
|
107
|
+
b = [args[:before]].flatten.compact.map(&:to_s).join(", ")
|
108
|
+
a = [args[ :after]].flatten.compact.map(&:to_s).join(", ")
|
109
|
+
b = b + ", " unless args[:before].nil? || args[:before].empty?
|
110
|
+
a = ", " + a unless args[ :after].nil? || args[ :after].empty?
|
111
|
+
alias_ = alias_.to_s.gsub(/\?$/, "") if suffix
|
112
|
+
|
113
|
+
class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 10
|
113
114
|
def #{alias_}#{suffix}(*args, &block)
|
114
115
|
#{wrap}(#{prefix}#{accessor}.send(
|
115
|
-
#{method.inspect}#{
|
116
|
+
#{method.inspect}, #{b}*args#{a}, &block
|
116
117
|
))
|
117
118
|
|
118
119
|
rescue Exception
|
119
|
-
|
120
|
+
if !Forwardable.debug && $@ && $@.respond_to?(:delete_if)
|
120
121
|
$@.delete_if do |source|
|
121
122
|
source =~ %r"#{Regexp.escape(__FILE__)}"o
|
122
123
|
end
|
@@ -179,5 +180,23 @@ module Forwardable
|
|
179
180
|
prefix, suffix, wrap
|
180
181
|
]
|
181
182
|
end
|
183
|
+
|
184
|
+
# ------------------------------------------------------------------------
|
185
|
+
|
186
|
+
private
|
187
|
+
def delegate_debug(str)
|
188
|
+
if Forwardable.debug && !Forwardable.debug.is_a?(TrueClass)
|
189
|
+
then Forwardable.debug.debug(
|
190
|
+
str
|
191
|
+
)
|
192
|
+
|
193
|
+
elsif Forwardable.debug
|
194
|
+
$stdout.puts(
|
195
|
+
"\n# ------\n\n", str
|
196
|
+
)
|
197
|
+
end
|
198
|
+
|
199
|
+
str
|
200
|
+
end
|
182
201
|
end
|
183
202
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forwardable-extended
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordon Bedwell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Forwardable with hash, and instance variable extensions.
|
14
14
|
email:
|