hash_ext 0.3.1 → 0.4.0

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
  SHA256:
3
- metadata.gz: '018157ec979a05e0de0fec38226ae6f85a7b389c35b6bcff170309958198474f'
4
- data.tar.gz: 7eb198a60d7b2f9c37666efba7c9efbe3bf46a96ac86b7fef14ec0185a05875d
3
+ metadata.gz: 5bb99caf8aab9c57468441c32b81ca57af6f62c721f02e2de3b50e35a25f844c
4
+ data.tar.gz: 954260a1450f803f93496417d5fdc27a2cae5ab55d29f177c5e64162c4e398f9
5
5
  SHA512:
6
- metadata.gz: 3ba3b53a2b9a4b86787203deae4c01c16def4e244d71c0211806f6e5390e5886ec401daf1914664f673ef8df6801c8af4b81803ac4af8612359bda6e0f4955fb
7
- data.tar.gz: 910eede3ee981ca4cd17a1db27390fffac1a67d18b3f0ac6d778954267a534d3351244394d0fd85acb8574353b7f7cd7619c519695a0794854d57027cef9d753
6
+ metadata.gz: bc8bb6beb185f177b5be28d3391a3f07f3202cda8adfcc41241cdcbf4fb1fbc1b40a7f6773bad729ae26e54d24b477f69d1a549753e48f54a4e39624afe5cc49
7
+ data.tar.gz: c083a701839254828d2d3d7dd588e62aa028421069128b58fb5c8956475e7c3001965d7a7b59c185302782b27577ecb6b1e9a4b546fc8e42892fc196cd984783
data/README.md CHANGED
@@ -92,6 +92,14 @@ hash[:a] = 3
92
92
  hash.keys # => [:a, :b, :c]
93
93
  ```
94
94
 
95
+ ### Nested
96
+ ```ruby
97
+ hash = Hash::Nested.new
98
+
99
+ hash[:level_1][:level_2][:level_3] = 'value'
100
+
101
+ hash # => {level_1: {level_2: {level_3: 'value'}}}
102
+ ```
95
103
 
96
104
  ## Contributing
97
105
 
@@ -0,0 +1,13 @@
1
+ class Hash
2
+ class Nested < Hash
3
+
4
+ def [](key)
5
+ if key? key
6
+ super(key)
7
+ else
8
+ self[key] = Nested.new
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module HashExt
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
data/lib/hash_ext.rb CHANGED
@@ -6,4 +6,5 @@ require_relative 'hash_ext/normalized'
6
6
  require_relative 'hash_ext/builder'
7
7
  require_relative 'hash_ext/indifferent'
8
8
  require_relative 'hash_ext/accessible'
9
- require_relative 'hash_ext/sorted'
9
+ require_relative 'hash_ext/sorted'
10
+ require_relative 'hash_ext/nested'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-15 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,6 +143,7 @@ files:
143
143
  - lib/hash_ext/accessible.rb
144
144
  - lib/hash_ext/builder.rb
145
145
  - lib/hash_ext/indifferent.rb
146
+ - lib/hash_ext/nested.rb
146
147
  - lib/hash_ext/normalized.rb
147
148
  - lib/hash_ext/sorted.rb
148
149
  - lib/hash_ext/version.rb