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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93b55369f46856b6cf664ec018d705709370e07d
4
- data.tar.gz: 70c5e0fca4d8e0646da79c68fae4dacaf1d97dea
3
+ metadata.gz: 5256b4a3e535f123be0295d4049fec34b64f441b
4
+ data.tar.gz: c5e6eb31c072e2b0c416db88ade397b1598eb2ab
5
5
  SHA512:
6
- metadata.gz: 85ab5a04cd496a674ac07c4b5c463317ea0a3068b01b22eccc9333ebf97178afd568234eda2d1b34a329ba7b85bfca42e1c35b2a512a177a17249ba36491883d
7
- data.tar.gz: 64526817b4fc243431acc698ce4aabd60d43396f4c1e1041c75223ca4000762093f254a8126fec2f6d41c53e11fb8cc34419508b36662a1042817292015c03a3
6
+ metadata.gz: 4e07873e37e0d041787493bdca2cc169d16e60551e548491ec70380dc1e7f0bedd5a21a5a1bb36c2e0b62cd649125c4e9a04e25b4c840e5558f2c430dad04964
7
+ data.tar.gz: d04857e49797516d9c812906c17888f261368cfbc87c1d67d2dc7528b4f9665ad7d80745ae0888a234de00f8508fb71195fb0e09198c430bca51282f0daf6ab0
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /*.gem
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 if self[prop].nil?
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 def dotify_hash(hash)
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
- private def to_dot?
40
+ def to_dot?
39
41
  self.use_dot_syntax || self.class.use_dot_syntax
40
42
  end
41
43
 
42
- private def setter?(method)
44
+ def setter?(method)
43
45
  method.last == "="
44
46
  end
45
47
 
46
- private def create_prop(method)
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
@@ -1,3 +1,3 @@
1
1
  module HashDot
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
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.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: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2016-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler