forward_to 0.1.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/.ruby-version +1 -1
- data/forward_to.gemspec +4 -4
- data/lib/forward_to/version.rb +1 -1
- data/lib/forward_to.rb +10 -6
- metadata +12 -12
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/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-
|
1
|
+
ruby-3.1.2
|
data/forward_to.gemspec
CHANGED
@@ -8,12 +8,12 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Claus Rasmussen"]
|
9
9
|
spec.email = ["ras@danak.dk"]
|
10
10
|
|
11
|
-
spec.summary = "
|
12
|
-
spec.description = "
|
13
|
-
spec.homepage = "
|
14
|
-
spec.required_ruby_version = ">= 2.4.0"
|
11
|
+
spec.summary = "Simple forwarding of methods"
|
12
|
+
spec.description = "Simple forwarding of methods"
|
13
|
+
spec.homepage = "https://github.com/clrgit/forward_to"
|
15
14
|
|
16
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/clrgit/forward_to.git"
|
17
17
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
19
19
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/forward_to/version.rb
CHANGED
data/lib/forward_to.rb
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
require_relative "forward_to/version"
|
4
4
|
|
5
5
|
module ForwardTo
|
6
|
-
class Error < StandardError; end
|
7
|
-
|
8
6
|
# Forward methods to member object. The arguments should be strings or symbols
|
9
7
|
#
|
10
8
|
# Forward to takes the first argument and creates methods for the rest of the
|
@@ -22,16 +20,22 @@ module ForwardTo
|
|
22
20
|
#
|
23
21
|
# a = MyArray.new
|
24
22
|
# a.size # -> 0
|
23
|
+
# a.empty? # -> true
|
24
|
+
# a[0] = 1
|
25
|
+
# a[0] # -> 1
|
25
26
|
#
|
26
27
|
# The target of #forward_to can be a method or a member (@variable) but has
|
27
28
|
# to be a symbol
|
28
29
|
#
|
29
30
|
def forward_to(target, *methods)
|
30
31
|
for method in Array(methods).flatten
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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")
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
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
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
like Rails #delegate but with a different syntax'
|
13
|
+
description: Simple forwarding of methods
|
15
14
|
email:
|
16
15
|
- ras@danak.dk
|
17
16
|
executables: []
|
@@ -28,11 +27,12 @@ files:
|
|
28
27
|
- forward_to.gemspec
|
29
28
|
- lib/forward_to.rb
|
30
29
|
- lib/forward_to/version.rb
|
31
|
-
homepage:
|
30
|
+
homepage: https://github.com/clrgit/forward_to
|
32
31
|
licenses: []
|
33
32
|
metadata:
|
34
|
-
homepage_uri:
|
35
|
-
|
33
|
+
homepage_uri: https://github.com/clrgit/forward_to
|
34
|
+
source_code_uri: https://github.com/clrgit/forward_to.git
|
35
|
+
post_install_message:
|
36
36
|
rdoc_options: []
|
37
37
|
require_paths:
|
38
38
|
- lib
|
@@ -40,15 +40,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: '0'
|
44
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
|
-
rubygems_version: 3.
|
51
|
-
signing_key:
|
50
|
+
rubygems_version: 3.3.18
|
51
|
+
signing_key:
|
52
52
|
specification_version: 4
|
53
|
-
summary:
|
53
|
+
summary: Simple forwarding of methods
|
54
54
|
test_files: []
|