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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e324925982b40a9a54c191ae4277dd4e89dc773ff66203d3a109dc50aa8d409e
4
- data.tar.gz: ee351092ac334d8f496dde7385914e90e5ea65831ceb390e169925997ad571e9
3
+ metadata.gz: '079c056657ce3bbdeba3086c185a38723c13ef0b357780a56ad5839e249f1ffe'
4
+ data.tar.gz: bc76638c1b0d7d480630d764c17078f4588684c1d00a0c9a820e6c9dfa0a4b59
5
5
  SHA512:
6
- metadata.gz: d4badf84c162ee10a8e41fde02a904d8935ca86b6e37dd0859068601c43a90a1d4d9401ad22c68fb9a93846e9a691f5defc7b86d345bd7a5a195692643d7f33b
7
- data.tar.gz: 285ad8105252e9b1688c8eb30f6c88e48189b4e75a9c04bf01ee09f75eafd8bbea1a06f4bd3253cd8a73cb460a4b51bdc67a2fe3fa2bb05e6abe0f2275ef8bfc
6
+ metadata.gz: c9b47190963da620d6da24fbef310fa40b9b522da5df19967e363f4a891f3f8db8d8253fd56172a424af9f1cbd0aad7a3c68ed03ebda4fe8e9591250deb56d71
7
+ data.tar.gz: 782a9d3e395a922e4ada9352095384ec3b97fc2aa30223a59eabe10e4023719c943654131949387b4565ea1b59a4ec48683d06e7c348c995b4e1bf2b741b12a0
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.7.1
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 = "Forward methods"
12
- spec.description = "Forwards instance methods to a member of an instance variable. It works like Rails #delegate but with a different syntax"
13
- spec.homepage = "http://github.com/clrgit/forward_to"
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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForwardTo
4
- VERSION = "0.1.0"
4
+ VERSION = "0.3.0"
5
5
  end
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
- if method =~ /=$/
32
- class_eval("def #{method}(*args) #{target}&.#{method}(*args) end")
33
- else
34
- class_eval("def #{method}(*args, &block) #{target}&.#{method}(*args, &block) end")
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.1.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: 2021-09-20 00:00:00.000000000 Z
11
+ date: 2022-09-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: 'Forwards instance methods to a member of an instance variable. It works
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: http://github.com/clrgit/forward_to
30
+ homepage: https://github.com/clrgit/forward_to
32
31
  licenses: []
33
32
  metadata:
34
- homepage_uri: http://github.com/clrgit/forward_to
35
- post_install_message:
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: 2.4.0
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.2.26
51
- signing_key:
50
+ rubygems_version: 3.3.18
51
+ signing_key:
52
52
  specification_version: 4
53
- summary: Forward methods
53
+ summary: Simple forwarding of methods
54
54
  test_files: []