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 +4 -4
- data/README.md +35 -1
- data/lib/hash_easy.rb +6 -0
- data/lib/hash_easy/bottomless_hash.rb +0 -6
- data/lib/hash_easy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7841ebd3dd7e3f45668769c6e2380adf361cd6d8
|
4
|
+
data.tar.gz: 49d41ae6ec0f8b908eb410a8c6783f565bbafe60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
data/lib/hash_easy/version.rb
CHANGED