hash_dot 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/hash.rb +12 -6
- data/lib/hash_dot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5256b4a3e535f123be0295d4049fec34b64f441b
|
4
|
+
data.tar.gz: c5e6eb31c072e2b0c416db88ade397b1598eb2ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e07873e37e0d041787493bdca2cc169d16e60551e548491ec70380dc1e7f0bedd5a21a5a1bb36c2e0b62cd649125c4e9a04e25b4c840e5558f2c430dad04964
|
7
|
+
data.tar.gz: d04857e49797516d9c812906c17888f261368cfbc87c1d67d2dc7528b4f9665ad7d80745ae0888a234de00f8508fb71195fb0e09198c430bca51282f0daf6ab0
|
data/.gitignore
CHANGED
data/lib/hash.rb
CHANGED
@@ -16,11 +16,11 @@ class Hash
|
|
16
16
|
|
17
17
|
prop = create_prop(method)
|
18
18
|
|
19
|
-
if self[prop].nil?
|
19
|
+
if self[prop].nil? && prop_present?(prop)
|
20
20
|
self[prop] = self.delete(prop.to_s)
|
21
21
|
end
|
22
22
|
|
23
|
-
super(method, args) and return
|
23
|
+
super(method, args) and return unless prop_present?(prop)
|
24
24
|
|
25
25
|
if setter?(method)
|
26
26
|
self[prop] = args.first
|
@@ -29,21 +29,27 @@ class Hash
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
private
|
32
|
+
private
|
33
|
+
|
34
|
+
def dotify_hash(hash)
|
33
35
|
hash.use_dot_syntax = true
|
34
36
|
|
35
37
|
hash.keys.each { |key| dotify_hash(hash[key]) if hash[key].is_a?(Hash) }
|
36
38
|
end
|
37
39
|
|
38
|
-
|
40
|
+
def to_dot?
|
39
41
|
self.use_dot_syntax || self.class.use_dot_syntax
|
40
42
|
end
|
41
43
|
|
42
|
-
|
44
|
+
def setter?(method)
|
43
45
|
method.last == "="
|
44
46
|
end
|
45
47
|
|
46
|
-
|
48
|
+
def create_prop(method)
|
47
49
|
setter?(method) ? method.chop : method
|
48
50
|
end
|
51
|
+
|
52
|
+
def prop_present?(prop)
|
53
|
+
self.has_key?(prop) || self.has_key?(prop.to_s)
|
54
|
+
end
|
49
55
|
end
|
data/lib/hash_dot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_dot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Steel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|