dot_hash 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dot_hash/properties.rb +12 -10
- data/lib/dot_hash/settings.rb +2 -1
- data/lib/dot_hash/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: a1b95611ef880619871a9f512c8ade7347246066
|
4
|
+
data.tar.gz: 649c5672f7b315cd5b340ad72eb9a0a6681970ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17e4590a50c2366dd2bc2a24498ab74da204da627d24069012c00250a77c95d1a56939249f2a42f5013ec6d538af9d3838410a0326d112b14c967d6670014eb5
|
7
|
+
data.tar.gz: d402862159c8f3d265d181a0d8dbfcdd63773239e4b853576120354a14683ae25d7ca6b3b83aade014ec10e461dd713b0ed7abe8f5e28db015b4800e044090de
|
data/lib/dot_hash/properties.rb
CHANGED
@@ -37,17 +37,15 @@ module DotHash
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def fetch(key, *args, &block)
|
40
|
-
|
41
|
-
value = hash.fetch(key, *args, &block)
|
40
|
+
key_sym = key.to_sym
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
value
|
47
|
-
else
|
48
|
-
cached[key] = true
|
49
|
-
hash[key] = hashify_item(value)
|
42
|
+
value = cached.fetch(key_sym) do
|
43
|
+
key = hash.has_key?(key_sym) ? key_sym : key.to_s
|
44
|
+
hashify_item hash.fetch(key, *args, &block)
|
50
45
|
end
|
46
|
+
|
47
|
+
return value if skip_cache?(key_sym, value)
|
48
|
+
cached[key_sym] = value
|
51
49
|
end
|
52
50
|
|
53
51
|
def has_key?(key)
|
@@ -59,7 +57,11 @@ module DotHash
|
|
59
57
|
private
|
60
58
|
|
61
59
|
def cached
|
62
|
-
@cached ||=
|
60
|
+
@cached ||= {}
|
61
|
+
end
|
62
|
+
|
63
|
+
def skip_cache?(key, value)
|
64
|
+
value.nil? or hash.respond_to?(key) or cached.has_key?(key)
|
63
65
|
end
|
64
66
|
|
65
67
|
def execute(key, *args, &block)
|
data/lib/dot_hash/settings.rb
CHANGED
data/lib/dot_hash/version.rb
CHANGED