dot_hash 1.1.1 → 1.1.2

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
  SHA1:
3
- metadata.gz: efb3b2993362ead2de92d08c09bc2be1c16fa363
4
- data.tar.gz: 45a3d494e3b60d2cf2bc69963f891d36ea1a1e04
3
+ metadata.gz: 2b6ebd2bd11ed70901028a8860a1de59a0e1f053
4
+ data.tar.gz: 15b93d20539be0617509dda4ceba4e7d5eab967e
5
5
  SHA512:
6
- metadata.gz: ab1ae26881dcb2bbf6e085d0b822135507c32baff2f1ea3c5715498ae7b5d5380e98e7667509f639255adb54c2cff8794caf3cb8cfdbdf6db7f1b44725c64b6f
7
- data.tar.gz: bcd109a1e99911734e3d29a901ab7f06e2ca73622ef3a593894999bbde3f7de141370439749b9a57ed756677886df8b900daa081e3c877df25e55bbc8c063c7c
6
+ metadata.gz: 9f50f36f75d32a5423659b0b84926c0fec927b26a29ac9b40b86313c1d1aced78e21468b298d305630291ac4b72134da2d79a4857313b38fd9b9e9bf3dd4d93e
7
+ data.tar.gz: 7d5faa7864cd10a212384601423bb277c18b33238f68d4e34043a86d76adfc56c28249561d5a54e62cc77ebbb941748ac2a65f0a04ce67c257cd103f46698404
@@ -40,8 +40,16 @@ module DotHash
40
40
  end
41
41
 
42
42
  def execute(key, *args, &block)
43
+ klass = self.class
44
+
43
45
  get_value(key) do
44
- hash.public_send(key, *args, &block)
46
+ hash.public_send(key, *args) do |*values|
47
+ values = values.flatten.map do |a|
48
+ a.is_a?(Hash) ? klass.new(a) : a
49
+ end
50
+
51
+ block.call(*values)
52
+ end
45
53
  end
46
54
  end
47
55
 
@@ -5,7 +5,7 @@ module DotHash
5
5
  end
6
6
 
7
7
  def load(*args)
8
- @hash = Loader.new(hash, *args).hash
8
+ hash.replace Loader.new(hash, *args).hash
9
9
  end
10
10
 
11
11
  class << self
@@ -1,3 +1,3 @@
1
1
  module DotHash
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -54,22 +54,37 @@ module DotHash
54
54
  end
55
55
  end
56
56
 
57
- describe "#[]" do
57
+ describe 'method delegation' do
58
58
  before do
59
- @properties = Properties.new user: { name: "dude" }
59
+ @properties = Properties.new({
60
+ ninja: {name: 'Naruto'}
61
+ })
60
62
  end
61
63
 
62
- it "accesses properties like a symbol hash" do
63
- assert_equal properties[:user][:name], "dude"
64
+ it 'converts innerhashes to Properties' do
65
+ assert_equal(
66
+ properties.map { |k, v| "#{k}: #{v.name}" },
67
+ ['ninja: Naruto']
68
+ )
64
69
  end
70
+ end
71
+ end
65
72
 
66
- it "accesses properties like a string hash" do
67
- assert_equal properties["user"]["name"], "dude"
68
- end
73
+ describe "#[]" do
74
+ before do
75
+ @properties = Properties.new user: { name: "dude" }
76
+ end
69
77
 
70
- it 'returns nil when value not present' do
71
- assert_nil properties['missing']
72
- end
78
+ it "accesses properties like a symbol hash" do
79
+ assert_equal properties[:user][:name], "dude"
80
+ end
81
+
82
+ it "accesses properties like a string hash" do
83
+ assert_equal properties["user"]["name"], "dude"
84
+ end
85
+
86
+ it 'returns nil when value not present' do
87
+ assert_nil properties['missing']
73
88
  end
74
89
  end
75
90
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dot_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Eden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-01 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake