hash_easy 0.0.2 → 0.0.3

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: a5c842b68e8d11c9449bd131427ce38bbd4e6b50
4
- data.tar.gz: d95082c9b85149b9da2dc062d3551ba28766d870
3
+ metadata.gz: 7841ebd3dd7e3f45668769c6e2380adf361cd6d8
4
+ data.tar.gz: 49d41ae6ec0f8b908eb410a8c6783f565bbafe60
5
5
  SHA512:
6
- metadata.gz: f8f3b4994bdb1f34d4d2e1c05bfd3016a4aa53cf0fca591267b8d8b731f658cefbd64e1ca0ba54c943e9ab982f9030b4b7f55b45686caf603c32935ade8fde4d
7
- data.tar.gz: 73c724af3d76c9ba060a82e6a27d869d57537af36532b973b494af546d48ec00ab26250e890c2ab4c92530183c4c20218b483a7492a9ca34cbebbd08045b7411
6
+ metadata.gz: c1281002edb715b3c08e5daea0821066544c08e4991d3266287681f61a1ea3b1d68602e11ceb401c1852021bf98c5a871a93b2f093b666337c422de8f0d12b1c
7
+ data.tar.gz: 848c26f3c2ddba0d2c53bcf2dc147924485e6a149bb259cbef949d083cc365d95a6e9e4c22bd366b901614278d9c74d28b6e72ccf2823ae58badd44a0b169e35
data/README.md CHANGED
@@ -20,7 +20,41 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ # Bottomless
24
+
25
+ Imagine that you need to create a hash with some levels:
26
+
27
+ ```ruby
28
+ my_hash = { }
29
+
30
+ %I(admin guest).each do |role|
31
+ my_hash[:data][:team][:roles][role] = { }
32
+ end
33
+ ```
34
+
35
+ This will result in an error:
36
+
37
+ ```
38
+ NoMethodError: undefined method `[]' for nil:NilClass
39
+ ```
40
+
41
+ So using HashEasy as the name say is easy to initializer a hash with multilevels, avoding the necessity to initialize or declare than first.
42
+
43
+ Here some examples:
44
+
45
+ ```ruby
46
+ my_hash = Hash.new.bottomless
47
+
48
+ %I(admin guest).each do |role|
49
+ my_hash[:data][:team][:roles][role] = { }
50
+ end
51
+ ```
52
+
53
+ And the result:
54
+
55
+ ```
56
+ {:data=>{:team=>{:roles=>{:admin=>{}, :guest=>{}}}}}
57
+ ```
24
58
 
25
59
  ## Contributing
26
60
 
data/lib/hash_easy.rb CHANGED
@@ -1,5 +1,11 @@
1
1
  require "hash_easy/version"
2
2
  require "hash_easy/bottomless_hash"
3
3
 
4
+ class Hash
5
+ def bottomless
6
+ HashEasy::BottomlessHash.from_hash(self)
7
+ end
8
+ end
9
+
4
10
  module HashEasy
5
11
  end
@@ -8,10 +8,4 @@ module HashEasy
8
8
  new.merge(hash)
9
9
  end
10
10
  end
11
-
12
- class Hash
13
- def bottomless
14
- BottomlessHash.from_hash(self)
15
- end
16
- end
17
11
  end
@@ -1,3 +1,3 @@
1
1
  module HashEasy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_easy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago da Anunciação