forward_to 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/forward_to/version.rb +1 -1
- data/lib/forward_to.rb +10 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '079c056657ce3bbdeba3086c185a38723c13ef0b357780a56ad5839e249f1ffe'
|
4
|
+
data.tar.gz: bc76638c1b0d7d480630d764c17078f4588684c1d00a0c9a820e6c9dfa0a4b59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9b47190963da620d6da24fbef310fa40b9b522da5df19967e363f4a891f3f8db8d8253fd56172a424af9f1cbd0aad7a3c68ed03ebda4fe8e9591250deb56d71
|
7
|
+
data.tar.gz: 782a9d3e395a922e4ada9352095384ec3b97fc2aa30223a59eabe10e4023719c943654131949387b4565ea1b59a4ec48683d06e7c348c995b4e1bf2b741b12a0
|
data/lib/forward_to/version.rb
CHANGED
data/lib/forward_to.rb
CHANGED
@@ -20,16 +20,22 @@ module ForwardTo
|
|
20
20
|
#
|
21
21
|
# a = MyArray.new
|
22
22
|
# a.size # -> 0
|
23
|
+
# a.empty? # -> true
|
24
|
+
# a[0] = 1
|
25
|
+
# a[0] # -> 1
|
23
26
|
#
|
24
27
|
# The target of #forward_to can be a method or a member (@variable) but has
|
25
28
|
# to be a symbol
|
26
29
|
#
|
27
30
|
def forward_to(target, *methods)
|
28
31
|
for method in Array(methods).flatten
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
case method
|
33
|
+
when /\[\]=/
|
34
|
+
class_eval("def #{method}(*args) #{target}&.#{method}(*args) end")
|
35
|
+
when /=$/
|
36
|
+
class_eval("def #{method}(args) #{target}&.#{method}(args) end")
|
37
|
+
else
|
38
|
+
class_eval("def #{method}(*args, &block) #{target}&.#{method}(*args, &block) end")
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forward_to
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Simple forwarding of methods
|
14
14
|
email:
|