wallaby-core 0.2.3 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/utils/wallaby/utils.rb +16 -1
- data/lib/wallaby/core/version.rb +1 -1
- 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: e40b4b93944ff58aa8a29b2ca4c270bf8f307e80cda249ab92a7fb895b38065f
|
4
|
+
data.tar.gz: 9680891625a9f143d5d584b496e57985a75f893abb7486f7ebe2aa024797582a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8313351ca3ccf0d48d2d364c374ac806a44be93324c95e6d461d6e6a9f0922fc0e54d113a6ae4c7512dbdb88f9625eb5192d6cf60c7b1febc1f68fb9c91a89ab
|
7
|
+
data.tar.gz: 719a0f01c66c28bdf0db046469af306d5939c9861b0f3073c36b2e92d7a659436e483e9b319b0d5a4ee345339e8b02e6f729b4da943fc3666a255cdac0eb1f4a
|
data/lib/utils/wallaby/utils.rb
CHANGED
@@ -7,7 +7,22 @@ module Wallaby
|
|
7
7
|
# @param object [Object]
|
8
8
|
# @return [Object] a clone object
|
9
9
|
def self.clone(object)
|
10
|
-
|
10
|
+
# NOTE: Neither marshal/deep_dup/dup are able to achieve real and correct deep copy,
|
11
|
+
# so here we need a custom solution below:
|
12
|
+
case object
|
13
|
+
when Hash
|
14
|
+
object
|
15
|
+
.each_with_object(object.class.new) { |(key, value), hash| hash[key] = clone(value) }
|
16
|
+
.tap { |hash| hash.default = object.default }
|
17
|
+
when Array
|
18
|
+
object.each_with_object(object.class.new) { |value, array| array << clone(value) }
|
19
|
+
when Class
|
20
|
+
# NOTE: `Class.dup` will turn the duplicate class into anonymous class
|
21
|
+
# therefore, we just return the Class itself here
|
22
|
+
object
|
23
|
+
else
|
24
|
+
object.dup
|
25
|
+
end
|
11
26
|
end
|
12
27
|
|
13
28
|
# @param object [Object, nil]
|
data/lib/wallaby/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wallaby-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tian Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|