delegate_it 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d9c6c96f253f6873747b2a99c57d3f597d37396
4
- data.tar.gz: 9eee5a76473094ed597cd28001b655513951fab1
3
+ metadata.gz: b54e8408c7b5f3f998ddb38bc4cab1e3ed41a323
4
+ data.tar.gz: 2a48cdc1da2cd8ea2c496a01e2e38c3f3c62ba13
5
5
  SHA512:
6
- metadata.gz: 34c3abf4b2e4057097d7b70dc22ac459e2068f6df944f8efed8340a40cda342fb32d55f99c0c7587808da3bc3f7a6403eace4b73f6523d4c4d0f65c80f43cfb5
7
- data.tar.gz: a632e9635d1914e0014e74219a11806561940baacc1d02fd60b94b7ebc3fb4c7f8abcc54df8776e02b4d55c1e846e51768e46f9c3b25f6d41e1188e8ddf0123a
6
+ metadata.gz: ee70d3a7896a7896a7f563a771d297873d6e4d6cb00ebfa140c7e44b33a6cc2c5bcca8eb0cfb39a59475fce13adfa1c70dcc089bbf123b66e1137eb24879f353
7
+ data.tar.gz: 4ddf92873d71eea10a6a24f9cb56f626a7dca6091a0d3190dbf0f2cd4f8a34a63a21466a4996a44369bb6ad81a85c036132577ac3e53004ba93004b0937f5640
@@ -11,7 +11,7 @@ module DelegateIt
11
11
  end
12
12
  end
13
13
 
14
- def method_missing(method, *)
14
+ def method_missing(method, *args)
15
15
  setting = @@delegated_settings.select do |s|
16
16
  s.name == method
17
17
  end.first
@@ -26,7 +26,7 @@ module DelegateIt
26
26
  if setting.options[:allow_nil] && !receiver
27
27
  nil
28
28
  else
29
- receiver.send(method)
29
+ receiver.send(method, *args)
30
30
  end
31
31
  else
32
32
  super
@@ -1,3 +1,3 @@
1
1
  module DelegateIt
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -3,17 +3,33 @@ require 'spec_helper'
3
3
 
4
4
  class Dummy
5
5
  include DelegateIt
6
- delegate :name, to: :name_delegate
6
+ delegate :name, :surname, to: :name_delegate
7
7
  delegate :hello, to: :no_exist, allow_nil: true
8
8
  delegate :there, to: :there_delegate, allow_nil: true
9
+ delegate :one, to: :args_delegate
10
+ delegate :print, to: :args_delegate
9
11
 
10
12
  def name_delegate
11
- Struct.new(:name).new('name_val')
13
+ Struct.new(:name, :surname).new('name_val', 'surname_val')
12
14
  end
13
15
 
14
16
  def there_delegate
15
17
  Struct.new(:there).new('there_val')
16
18
  end
19
+
20
+ def args_delegate
21
+ dynamic_class = Class.new do
22
+ def one count
23
+ ('one '* count).strip
24
+ end
25
+
26
+ def print(word, count)
27
+ ((word+' ') * count).strip
28
+ end
29
+ end
30
+
31
+ dynamic_class.new
32
+ end
17
33
  end
18
34
 
19
35
  describe 'DelegateIt' do
@@ -22,8 +38,21 @@ describe 'DelegateIt' do
22
38
  end
23
39
 
24
40
  describe "standard delegation" do
25
- it "works" do
26
- expect(subject.name).to eq 'name_val'
41
+ context "without parameters" do
42
+ it "works" do
43
+ expect(subject.name).to eq 'name_val'
44
+ expect(subject.surname).to eq 'surname_val'
45
+ end
46
+ end
47
+
48
+ context "with parameters" do
49
+ it "works with one" do
50
+ expect(subject.one(3)).to eq 'one one one'
51
+ end
52
+
53
+ it "works with more params" do
54
+ expect(subject.print('more', 3)).to eq 'more more more'
55
+ end
27
56
  end
28
57
  end
29
58
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delegate_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb