immutable_struct_ex 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6899b83fdcbc4b1667c1e4f52d5684f02951906db7edb8803cddc3aafdd13f4
4
- data.tar.gz: 71d5b7273ac7957ff121a8a5956c464eeb6d6fc406e401d140bcfd011a9b7938
3
+ metadata.gz: d9a93f45b29cdb392b541307fc4d6cf8299cb94b2c70611c65d5837d006be43c
4
+ data.tar.gz: 7e9239039e3226bd00ca971716b7470d620d11dc1997182cbe8c388af7b36a47
5
5
  SHA512:
6
- metadata.gz: c6984a42cc429d6670cc27575c3454fc697f71632d9f79216fadd12972df49c1ec4c0ac2f7f80a773e8c871bc32c7a76ae7dfcd245f50dbd8decba7bdbccb20c
7
- data.tar.gz: d016604712962f74e086a4af92488762c2f66a4f106d85c650430067077ebfbbc71cc32ed1d0d233d79be8a7bf8632bb5d3bb5b82a275d625814a97882b9b9a2
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- immutable_struct_ex (0.1.0)
4
+ immutable_struct_ex (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ImmutableStructEx
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
@@ -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.instance_eval { undef :"#{method}=" }
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.0
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 00:00:00.000000000 Z
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