clean-hash 0.5.9 → 0.5.10
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/.version +1 -1
- data/lib/clean-hash/types/indifferent_type.rb +7 -1
- data/lib/clean-hash/types/strict_type.rb +11 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aa268efe06af7303de7c0682b5a2609d24200031d735f4656a367def8e40107
|
4
|
+
data.tar.gz: 9cd5fad76a9cbecc2809b5c66882d18d19f88c2f7fca85d61aa583a5528ecea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfc3ed70a5f0e28ee81ab9510f01e239839bf006028984ba225dc7c998500cd2c07d17095afb6c6e7edde75e7113c74405969b39bda13f7b8ddec1b50759797e
|
7
|
+
data.tar.gz: 514436d07e37905ef9d57079db2e3a98ccde96ac58b5d8ee4645654d0f71d56b622adae29add383f7b56c3176c95773b599e61e84b0c2b40a1dc8b97449e1a75
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.10
|
@@ -2,15 +2,17 @@
|
|
2
2
|
|
3
3
|
class CleanHash
|
4
4
|
class Strict < Indifferent
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def
|
13
|
-
|
5
|
+
private
|
6
|
+
|
7
|
+
# raise error if accessing hash with method and key not found
|
8
|
+
# stict_hash = { foo: :bar }.to_ch :strict
|
9
|
+
# stict_hash[:not_found] # nil
|
10
|
+
# stict_hash.foo # :bar
|
11
|
+
# stict_hash.not_found # ArgumentError
|
12
|
+
def _method_missing_key key
|
13
|
+
self[key].tap do |value|
|
14
|
+
raise ArgumentError.new('Key not found: %s' % key) if value.nil?
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|