clean-hash 0.5.10 → 0.5.11
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/hash_pollute.rb +4 -0
- data/lib/clean-hash/types/struct_type.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b4ab8e9884ce9634b844cd3c4376ff353bbe1017279b49e0ce0cbd6d3c40301
|
4
|
+
data.tar.gz: dfe2c01fa31add7234eaa6fb05c62cdbb4ea1a6eccd79a02df40076e4db2a9e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6af7a328d16dffe592cb6cbd4d341b5623b293efac278efb71f1dab6ca6bd0a9763a7f1f6ca5a18351c6d622595e639f89426861f3e8702b3f42e93fdffb576
|
7
|
+
data.tar.gz: f763eb0ef805f540e0133f381474d999cdbd63b62bb349b1208b7aad756e1243fd2859fe6b71c877b12ab9612320e47c5500a1fbe932195fc4a97aa99b72cf40
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.11
|
@@ -14,6 +14,10 @@ class CleanHash
|
|
14
14
|
|
15
15
|
def to_ch mode=nil
|
16
16
|
if mode.is_a?(Array)
|
17
|
+
if not_alowed = (keys - mode).first
|
18
|
+
raise ArgumentError.new('CleanHash option "%s" is not alowed (%s)' % [not_alowed, mode.join(', ')])
|
19
|
+
end
|
20
|
+
|
17
21
|
mode.each { |el| self[el] = nil if self[el].nil? }
|
18
22
|
::CleanHash.create_struct self
|
19
23
|
else
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# Creates dynamic struct based on arguments
|
2
2
|
|
3
3
|
class CleanHash
|
4
|
-
|
4
|
+
CH_STRUCTS ||= {}
|
5
5
|
|
6
6
|
def self.create_struct hash
|
7
7
|
raise ArgumentError.new('Not a hash') unless hash.is_a?(Hash)
|
8
8
|
|
9
9
|
name = 'DynStruct_' + hash.keys.join('_')
|
10
|
-
|
10
|
+
CH_STRUCTS[name] ||= ::Struct.new(name, *hash.keys.sort)
|
11
11
|
|
12
|
-
|
12
|
+
CH_STRUCTS[name].new.tap do |o|
|
13
13
|
hash.each do |k, v|
|
14
14
|
o.send('%s=' % k, v) unless v.nil?
|
15
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clean-hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dino Reic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|