nested_hash 0.2.0 → 0.2.1
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.
- data/lib/nested_hash.rb +4 -7
- data/lib/nested_hash/version.rb +1 -1
- metadata +3 -3
data/lib/nested_hash.rb
CHANGED
@@ -11,17 +11,14 @@ class NestedHash < Hash
|
|
11
11
|
|
12
12
|
def set(key,value)
|
13
13
|
key = sanitize_long_key(key)
|
14
|
+
|
14
15
|
if is_valid_key?(key)
|
15
|
-
|
16
|
+
look_for(key,value)
|
16
17
|
elsif copy_invalid_keys?
|
17
18
|
copy(key,value)
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
def get(key)
|
22
|
-
key = sanitize_long_key(key)
|
23
|
-
end
|
24
|
-
|
25
22
|
def compact_arrays!(element = self)
|
26
23
|
element.each do |item|
|
27
24
|
item.compact! if item.is_a?(Array)
|
@@ -30,7 +27,7 @@ class NestedHash < Hash
|
|
30
27
|
end
|
31
28
|
|
32
29
|
|
33
|
-
def
|
30
|
+
def look_for(key,value, write = true)
|
34
31
|
keys = key.split(".").map{|k| sanitize_key(k)}
|
35
32
|
|
36
33
|
previous = keys.shift
|
@@ -47,7 +44,7 @@ class NestedHash < Hash
|
|
47
44
|
end
|
48
45
|
|
49
46
|
def get(key)
|
50
|
-
|
47
|
+
look_for(key,nil, false)
|
51
48
|
end
|
52
49
|
|
53
50
|
protected
|
data/lib/nested_hash/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nested_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Guillermo A\xCC\x81lvarez"
|