isomorfeus-transport 23.6.0.rc3 → 23.6.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isomorfeus/core_ext/hash_ext.rb +77 -77
- data/lib/isomorfeus/transport/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d5a337a47da0a199bc987865edf18f97858288f7dfe7901b6bad0dbc40d3f1e
|
4
|
+
data.tar.gz: c564283dff2e184318a3617c290cb15675a42d56689069b01555667a62b1ce6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ca77316e1285cfe7c9fbc409ca31e0fd0879610398e9ce3e37594c63ea02df2e9835eb78945f2a18538d7cbc574e5b7d113ca25894d99e1103356b340410d4d
|
7
|
+
data.tar.gz: 903c65c56b7f4d621ed12edbc35094333a0cbdcf12d3843cf388e1802065534837331ad52aa03c60ff19295bfbb19620159e19a043c02bf53a5dcc67ad063be0
|
@@ -1,77 +1,77 @@
|
|
1
|
-
class Hash
|
2
|
-
def deep_freeze
|
3
|
-
each_value do |value|
|
4
|
-
value.deep_freeze if value.is_a?(Hash)
|
5
|
-
end
|
6
|
-
self
|
7
|
-
end
|
8
|
-
|
9
|
-
if RUBY_ENGINE == 'opal'
|
10
|
-
def self.recursive_new(obj)
|
11
|
-
%x{
|
12
|
-
var key, val;
|
13
|
-
for (var key in obj) {
|
14
|
-
val = obj[key];
|
15
|
-
if (val !== null && typeof val === "object" && !val.$$is_array && !val.$$is_hash && !Array.isArray(val)) {
|
16
|
-
obj[key] = #{Hash.recursive_new(`val`)};
|
17
|
-
}
|
18
|
-
}
|
19
|
-
return Opal.hash(obj);
|
20
|
-
}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# originally taken from: https://github.com/rails/rails/blob/main/activesupport/lib/active_support/core_ext/object/deep_dup.rb
|
25
|
-
# Returns a deep copy of hash.
|
26
|
-
#
|
27
|
-
# hash = { a: { b: 'b' } }
|
28
|
-
# dup = hash.deep_dup
|
29
|
-
# dup[:a][:c] = 'c'
|
30
|
-
#
|
31
|
-
# hash[:a][:c] # => nil
|
32
|
-
# dup[:a][:c] # => "c"
|
33
|
-
def deep_dup
|
34
|
-
hash = dup
|
35
|
-
each_pair do |key, value|
|
36
|
-
if ::String === key || ::Symbol === key
|
37
|
-
hash[key] = value.deep_dup
|
38
|
-
else
|
39
|
-
hash.delete(key)
|
40
|
-
hash[key.deep_dup] = value.deep_dup
|
41
|
-
end
|
42
|
-
end
|
43
|
-
hash
|
44
|
-
end
|
45
|
-
|
46
|
-
# originally taken from: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
|
47
|
-
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
48
|
-
#
|
49
|
-
# h1 = { a: true, b: { c: [1, 2, 3] } }
|
50
|
-
# h2 = { a: false, b: { x: [3, 4, 5] } }
|
51
|
-
#
|
52
|
-
# h1.deep_merge(h2) # => { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
|
53
|
-
#
|
54
|
-
# Like with Hash#merge in the standard library, a block can be provided
|
55
|
-
# to merge values:
|
56
|
-
#
|
57
|
-
# h1 = { a: 100, b: 200, c: { c1: 100 } }
|
58
|
-
# h2 = { b: 250, c: { c1: 200 } }
|
59
|
-
# h1.deep_merge(h2) { |key, this_val, other_val| this_val + other_val }
|
60
|
-
# # => { a: 100, b: 450, c: { c1: 300 } }
|
61
|
-
def deep_merge(other_hash, &block)
|
62
|
-
dup.deep_merge!(other_hash, &block)
|
63
|
-
end
|
64
|
-
|
65
|
-
# Same as +deep_merge+, but modifies +self+.
|
66
|
-
def deep_merge!(other_hash, &block)
|
67
|
-
merge!(other_hash) do |key, this_val, other_val|
|
68
|
-
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
|
69
|
-
this_val.deep_merge(other_val, &block)
|
70
|
-
elsif block_given?
|
71
|
-
block.call(key, this_val, other_val)
|
72
|
-
else
|
73
|
-
other_val
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
1
|
+
class Hash
|
2
|
+
def deep_freeze
|
3
|
+
each_value do |value|
|
4
|
+
value.deep_freeze if value.is_a?(Hash)
|
5
|
+
end
|
6
|
+
self
|
7
|
+
end
|
8
|
+
|
9
|
+
if RUBY_ENGINE == 'opal'
|
10
|
+
def self.recursive_new(obj)
|
11
|
+
%x{
|
12
|
+
var key, val;
|
13
|
+
for (var key in obj) {
|
14
|
+
val = obj[key];
|
15
|
+
if (val !== null && typeof val === "object" && !val.$$is_array && !val.$$is_hash && !Array.isArray(val)) {
|
16
|
+
obj[key] = #{Hash.recursive_new(`val`)};
|
17
|
+
}
|
18
|
+
}
|
19
|
+
return Opal.hash(obj);
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# originally taken from: https://github.com/rails/rails/blob/main/activesupport/lib/active_support/core_ext/object/deep_dup.rb
|
25
|
+
# Returns a deep copy of hash.
|
26
|
+
#
|
27
|
+
# hash = { a: { b: 'b' } }
|
28
|
+
# dup = hash.deep_dup
|
29
|
+
# dup[:a][:c] = 'c'
|
30
|
+
#
|
31
|
+
# hash[:a][:c] # => nil
|
32
|
+
# dup[:a][:c] # => "c"
|
33
|
+
def deep_dup
|
34
|
+
hash = dup
|
35
|
+
each_pair do |key, value|
|
36
|
+
if ::String === key || ::Symbol === key
|
37
|
+
hash[key] = value.deep_dup
|
38
|
+
else
|
39
|
+
hash.delete(key)
|
40
|
+
hash[key.deep_dup] = value.deep_dup
|
41
|
+
end
|
42
|
+
end
|
43
|
+
hash
|
44
|
+
end
|
45
|
+
|
46
|
+
# originally taken from: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
|
47
|
+
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
48
|
+
#
|
49
|
+
# h1 = { a: true, b: { c: [1, 2, 3] } }
|
50
|
+
# h2 = { a: false, b: { x: [3, 4, 5] } }
|
51
|
+
#
|
52
|
+
# h1.deep_merge(h2) # => { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
|
53
|
+
#
|
54
|
+
# Like with Hash#merge in the standard library, a block can be provided
|
55
|
+
# to merge values:
|
56
|
+
#
|
57
|
+
# h1 = { a: 100, b: 200, c: { c1: 100 } }
|
58
|
+
# h2 = { b: 250, c: { c1: 200 } }
|
59
|
+
# h1.deep_merge(h2) { |key, this_val, other_val| this_val + other_val }
|
60
|
+
# # => { a: 100, b: 450, c: { c1: 300 } }
|
61
|
+
def deep_merge(other_hash, &block)
|
62
|
+
dup.deep_merge!(other_hash, &block)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Same as +deep_merge+, but modifies +self+.
|
66
|
+
def deep_merge!(other_hash, &block)
|
67
|
+
merge!(other_hash) do |key, this_val, other_val|
|
68
|
+
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
|
69
|
+
this_val.deep_merge(other_val, &block)
|
70
|
+
elsif block_given?
|
71
|
+
block.call(key, this_val, other_val)
|
72
|
+
else
|
73
|
+
other_val
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 23.6.0.
|
4
|
+
version: 23.6.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -190,14 +190,14 @@ dependencies:
|
|
190
190
|
requirements:
|
191
191
|
- - '='
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version: 23.6.0.
|
193
|
+
version: 23.6.0.rc4
|
194
194
|
type: :development
|
195
195
|
prerelease: false
|
196
196
|
version_requirements: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
198
|
- - '='
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version: 23.6.0.
|
200
|
+
version: 23.6.0.rc4
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: rake
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|