immutable_struct_ex 0.1.0 → 0.1.1
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/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/lib/immutable_struct_ex/version.rb +1 -1
- data/lib/immutable_struct_ex.rb +18 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9a93f45b29cdb392b541307fc4d6cf8299cb94b2c70611c65d5837d006be43c
|
4
|
+
data.tar.gz: 7e9239039e3226bd00ca971716b7470d620d11dc1997182cbe8c388af7b36a47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51ad57864c9b892f7c5327bfba585f5e511b5eeb7dd1b707b5a284fa31b3f3b06c5ef14f808adb7e6d1df0ab372e1ca117843eefc9ec6dcd02265e34c7b08574
|
7
|
+
data.tar.gz: caa878e4c999c39efd6f55e605518c92e330aa9f9a407cfaea4c9f33196feb4df29224784433623a70c701280409491ce8182cb2cb97a135a2c6117f94886650
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
### 0.1.1
|
2
|
+
* Enhancements
|
3
|
+
* Added this CHANGELOG.md
|
4
|
+
* Bug fix
|
5
|
+
* Equality method #== did not work when comparing objects whose underlying hashes were equal.
|
6
|
+
* Added #== method to compare underlying hashes by calling a.to_h == b.to_h.
|
7
|
+
|
8
|
+
### 0.1.0
|
9
|
+
* Initial release.
|
data/Gemfile.lock
CHANGED
data/lib/immutable_struct_ex.rb
CHANGED
@@ -9,9 +9,26 @@ module ImmutableStructEx
|
|
9
9
|
options_struct = Struct.new(*hash.keys, keyword_init: true, &block)
|
10
10
|
options_struct.new(**hash).tap do |struct|
|
11
11
|
[:[], *struct.members].each do |method|
|
12
|
-
struct
|
12
|
+
evaluate(struct) do
|
13
|
+
<<~RUBY
|
14
|
+
undef :"#{method}="
|
15
|
+
RUBY
|
16
|
+
end
|
17
|
+
end
|
18
|
+
evaluate(struct) do
|
19
|
+
<<~RUBY
|
20
|
+
def ==(object)
|
21
|
+
return false unless object.respond_to? :to_h
|
22
|
+
|
23
|
+
to_h == object.to_h
|
24
|
+
end
|
25
|
+
RUBY
|
13
26
|
end
|
14
27
|
end
|
15
28
|
end
|
29
|
+
|
30
|
+
def evaluate(struct)
|
31
|
+
struct.instance_eval yield
|
32
|
+
end
|
16
33
|
end
|
17
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immutable_struct_ex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gene M. Angelo, Jr.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- ".rubocop.yml"
|
162
162
|
- ".ruby-version"
|
163
163
|
- ".travis.yml"
|
164
|
+
- CHANGELOG.md
|
164
165
|
- CODE_OF_CONDUCT.md
|
165
166
|
- Gemfile
|
166
167
|
- Gemfile.lock
|