wholeable 2.0.0 → 2.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22a0b004027d8ea27c1d2ca4ec1c9df4c86b9b3f30f568454c8d0619a778cf6d
4
- data.tar.gz: c1edd95f553852b03984f9a24d205cdad50d80fa5bfdad7b5955371e7a5242cd
3
+ metadata.gz: 449fc75d34cc505190e11670452eed7f8a1f58d7f24f2df36fe24857f055a188
4
+ data.tar.gz: c958dca76cc2446384579ec537961f77da10c40680c71b10768335dead1f919e
5
5
  SHA512:
6
- metadata.gz: 92b81b6a566b0bdc4021eb1cd06362c33510104177dd13c7c4d5d17edef56b1607ff539ca1005ace1e2d686d198c8a4e211c9c1d2863c283f68c377bb3425431
7
- data.tar.gz: 59fa9a85e0902728ef204fb27df3044aaec1d319aaf84657e6093ade027b3a3c1954db547c0724448b9f46b67bae8cd55612a50be2ec1d4f8c451c485065ae66
6
+ metadata.gz: 8d551292b8f50f38f9fccfa1bae6a8e9ff174c82a76106f94dac6f748a4cff6a8bf1628d296455b8b3a61ceef0752e70ce709255195477b5f4ab57c8792620e5
7
+ data.tar.gz: f143f59acccf45cfd19042715d6ad3d0619a2755a28e6c7b39f2288aa0cde174454cec77c6864b8e7418c2ef662883669eb94b1cb2b1d1fda2961c9b7a370590
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -10,10 +10,10 @@
10
10
 
11
11
  = Wholeable
12
12
 
13
- Wholeable allows you to turn your object into a _whole value object_ by ensuring object equality is determined by the values of the object instead of by identity. Whole value objects -- or value objects in general -- have the following traits as noted via link:https://en.wikipedia.org/wiki/Value_object[Wikipedia]:
13
+ Wholeable allows you to turn your object into a _whole value object_ by ensuring object equality is determined by the values of the object instead of object identity. Whole value objects -- or value objects in general -- have the following traits:
14
14
 
15
15
  * Equality is determined by the values that make up an object and not by link:https://en.wikipedia.org/wiki/Identity_(object-oriented_programming)[identity] (i.e. memory address) which is the default behavior for all {ruby_link} objects except for {data_link} and {structs_link}.
16
- * Identity remains unique since two objects can have the same values but different identity. This means `BasicObject#equal?` is never overwritten -- which is strongly discouraged -- as per link:https://rubyapi.org/o/basicobject#method-i-3D-3D[BasicObject] documentation.
16
+ * Identity remains unique since two objects can have the same values but different identity. This means `BasicObject#equal?` is never overwritten -- which is strongly discouraged -- as per link:https://docs.ruby-lang.org/en/master/BasicObject.html[BasicObject] documentation.
17
17
  * Value objects should be immutable (i.e. frozen) by default. This implementation enforces a strict adherence to immutability in order to ensure value objects remain equal and discourage mutation.
18
18
 
19
19
  toc::[]
@@ -70,6 +70,8 @@ To use, include Wholeable along with a list of attributes that make up your whol
70
70
 
71
71
  [source,ruby]
72
72
  ----
73
+ require "wholeable"
74
+
73
75
  class Person
74
76
  include Wholeable[:name, :email]
75
77
 
@@ -162,10 +164,12 @@ Both methods work but use `.[]` when supplying arguments and `.new` when you don
162
164
 
163
165
  === Mutability
164
166
 
165
- All whole value objects are frozen by default. You can change behavior by specifying whether instances should be mutable by passing `kind: :mutable` as a keyword argument. Example:
167
+ Instances are frozen by default. You can change behavior by specifying whether instances should be mutable by passing `kind: :mutable` as a keyword argument. Example:
166
168
 
167
169
  [source,ruby]
168
170
  ----
171
+ require "wholeable"
172
+
169
173
  class Person
170
174
  include Wholeable[:name, :email, kind: :mutable]
171
175
 
@@ -196,6 +200,8 @@ Unlike {data_link} or {structs_link}, you can subclass a whole value object. Exa
196
200
 
197
201
  [source,ruby]
198
202
  ----
203
+ require "wholeable"
204
+
199
205
  class Person
200
206
  include Wholeable[:name]
201
207
 
@@ -229,6 +235,8 @@ If your ancestry is a mixed (immutable and mutable) then behavior is specific to
229
235
 
230
236
  [source,ruby]
231
237
  ----
238
+ require "wholeable"
239
+
232
240
  class Parent
233
241
  include Wholeable[:one]
234
242
 
@@ -255,10 +263,12 @@ child.frozen? # false
255
263
 
256
264
  Notice, when attempting to mutate the `one` attribute, you get a `NoMethodError`. This is because `#one=` is defined by the _immutable_ parent while `#two=` is defined on the _mutable_ child.
257
265
 
258
- If you the flip mutability of your ancestry, you can make your parent mutable while the child immutable for different behavior. Example:
266
+ If you the flip mutability of your ancestry, you can make your parent mutable while the child is immutable with different behavior. Example:
259
267
 
260
268
  [source,ruby]
261
269
  ----
270
+ require "wholeable"
271
+
262
272
  class Parent
263
273
  include Wholeable[:one, kind: :mutable]
264
274
 
@@ -296,47 +306,59 @@ Whole values can be broken via the following situations:
296
306
 
297
307
  == Performance
298
308
 
299
- The performance of this gem is good but definitely slower than native support for {data_link} and {structs_link} because they are written in C. To illustrate, here's a micro benchmark for comparison:
309
+ The performance of this gem is slightly slower than native support for {data_link} and {structs_link} because they are written in C. To illustrate, here's a micro benchmark for comparison:
300
310
 
301
311
  ----
302
312
  INITIALIZATION
303
313
 
304
- ruby 3.3.5 (2024-09-03 revision ef084cc8f4) +YJIT [arm64-darwin23.6.0]
314
+ ruby 4.0.1 (2026-01-13 revision e04267a14b) +YJIT +PRISM [arm64-darwin25.2.0]
305
315
  Warming up --------------------------------------
306
- Data 470.027k i/100ms
307
- Struct 422.010k i/100ms
308
- Whole 805.945k i/100ms
316
+ Data 411.580k i/100ms
317
+ Equalizer 2.225M i/100ms
318
+ Equatable 2.321M i/100ms
319
+ Struct 455.823k i/100ms
320
+ Wholeable 859.120k i/100ms
309
321
  Calculating -------------------------------------
310
- Data 4.750M1.1%) i/s (210.53 ns/i) - 23.971M in 5.047225s
311
- Struct 4.579M1.1%) i/s (218.38 ns/i) - 23.211M in 5.069228s
312
- Whole 9.408M1.2%) i/s (106.29 ns/i) - 47.551M in 5.055033s
322
+ Data 4.903M8.8%) i/s (203.94 ns/i) - 24.695M in 5.072786s
323
+ Equalizer 25.434M8.5%) i/s (39.32 ns/i) - 126.805M in 5.018058s
324
+ Equatable 25.399M7.9%) i/s (39.37 ns/i) - 127.656M in 5.053633s
325
+ Struct 4.811M (± 7.7%) i/s (207.85 ns/i) - 24.159M in 5.048700s
326
+ Wholeable 10.649M (± 8.9%) i/s (93.91 ns/i) - 53.265M in 5.044738s
313
327
 
314
328
  Comparison:
315
- Whole: 9407938.7 i/s - 1.60x slower
316
- Data: 4750013.8 i/s - 3.17x slower
317
- Struct: 4579253.1 i/s - 3.28x slower
329
+ Equalizer: 25434240.3 i/s
330
+ Equatable: 25398808.9 i/s - same-ish: difference falls within error
331
+ Wholeable: 10648737.2 i/s - 2.39x slower
332
+ Data: 4903352.0 i/s - 5.19x slower
333
+ Struct: 4811046.3 i/s - 5.29x slower
318
334
 
319
- BEHAVIOR
335
+ MESSAGING
320
336
 
321
- ruby 3.3.5 (2024-09-03 revision ef084cc8f4) +YJIT [arm64-darwin23.6.0]
337
+ ruby 4.0.1 (2026-01-13 revision e04267a14b) +YJIT +PRISM [arm64-darwin25.2.0]
322
338
  Warming up --------------------------------------
323
- Data 129.006k i/100ms
324
- Struct 129.832k i/100ms
325
- Wholeable 78.861k i/100ms
339
+ Data 125.714k i/100ms
340
+ Equalizer 97.991k i/100ms
341
+ Equatable 94.801k i/100ms
342
+ Struct 121.077k i/100ms
343
+ Wholeable 96.806k i/100ms
326
344
  Calculating -------------------------------------
327
- Data 1.336M 3.6%) i/s (748.33 ns/i) - 6.708M in 5.027517s
328
- Struct 1.341M 1.7%) i/s (745.89 ns/i) - 6.751M in 5.037050s
329
- Wholeable 816.232k1.9%) i/s (1.23 μs/i) - 4.101M in 5.025751s
345
+ Data 1.368M12.1%) i/s (731.11 ns/i) - 6.789M in 5.052046s
346
+ Equalizer 997.443k11.4%) i/s (1.00 μs/i) - 4.998M in 5.074622s
347
+ Equatable 996.404k9.6%) i/s (1.00 μs/i) - 5.024M in 5.087767s
348
+ Struct 1.429M (±10.0%) i/s (699.99 ns/i) - 7.144M in 5.051871s
349
+ Wholeable 967.377k (±10.7%) i/s (1.03 μs/i) - 4.840M in 5.060414s
330
350
 
331
351
  Comparison:
332
- Struct: 1340687.5 i/s
333
- Data: 1336304.1 i/s - same-ish: difference falls within error
334
- Wholeable: 816232.0 i/s - 1.64x slower
352
+ Struct: 1428586.9 i/s
353
+ Data: 1367792.5 i/s - same-ish: difference falls within error
354
+ Equalizer: 997443.1 i/s - 1.43x slower
355
+ Equatable: 996404.3 i/s - 1.43x slower
356
+ Wholeable: 967377.2 i/s - 1.48x slower
335
357
  ----
336
358
 
337
- While the above isn't bad, you can definitely see this gem is slower than Ruby's own native objects when interacting with it despite being faster upon initialization.
359
+ While the above isn't bad, you can see this gem is slower than Ruby's own native objects during interaction despite being faster upon initialization.
338
360
 
339
- Default to using {data_link} or {structs_link} but, if you find yourself needing a whole value object with more behavior than what a `Data` or `Struct` can provide, then this gem is a good solution.
361
+ Prefer using {data_link} or {structs_link} first but, if you find yourself needing a whole value object with more behavior than what a `Data` or `Struct` can provide, then this gem is a good solution.
340
362
 
341
363
  == Development
342
364
 
data/wholeable.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "wholeable"
5
- spec.version = "2.0.0"
5
+ spec.version = "2.2.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/wholeable"
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wholeable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -9,9 +9,9 @@ bindir: bin
9
9
  cert_chain:
10
10
  - |
11
11
  -----BEGIN CERTIFICATE-----
12
- MIIENjCCAp6gAwIBAgIBAjANBgkqhkiG9w0BAQsFADBBMQ8wDQYDVQQDDAZicm9v
12
+ MIIENjCCAp6gAwIBAgIBAzANBgkqhkiG9w0BAQsFADBBMQ8wDQYDVQQDDAZicm9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E8kQGGKskI
32
- Kkm6QT474hZl7MpwiJjWgW313CR7jUEekQahX1QxCxHPI7LSrKpno0plH3uWIOQp
33
- KUlkb9uyACBgyRO52ZHiDVI8YvtU5O/j9pSes9/3XgvBeC1onx4qWp+uRX7eVsYS
34
- GiijocTc3enZVrXERetaXj8/9XWs3fB3HWY=
26
+ F5wykJEVMA0GCSqGSIb3DQEBCwUAA4IBgQAG+ykjp+DIXSybGEtX+/ve974mYfN6
27
+ 8U7qcVfRM+qDSOZ+97iu30qUTbVAKIHlHCDKRn3SgOffDUB5VU2MsJBh/3TPKWBZ
28
+ anB/uzMcwOfru+qyA3b7ZFqZzRLWmR5FtPObFxc0gYMT3YvLNHk2Nb9Vjq/PoiGG
29
+ e75PXweDOokwDA5m1gMOz1rdp/dlGMXkSFQg94PPVyUKXgO4VzWTgePSDxOIL+v6
30
+ +OWV6AaEH9BaqxnmdA5ubi0L7bhl0gbN92FxpNO3kpTjww8kme856a+wCK3qyM5w
31
+ 7ZLbUexynDN0Au8eSpT2Bf6ztGmB1S9ffzDJsGX1/lkpMIB51e48Xe2+gzzOgemk
32
+ CdZaGupj6WkarnT8kh/cPtyA5ax4rGX6GOS8meGxzkv8Uy0JSEOYAp6wLfIisYZp
33
+ IJBIXIOkwKKJ0eB5YHrUSJxzpP4LlcIg/eTftaXmJdYjy+2VRrCZYDjfguyLmMjR
34
+ KR9w4/Fjvqy87kCHmxMWa6IL2Vzt1Clm2cA=
35
35
  -----END CERTIFICATE-----
36
36
  date: 1980-01-02 00:00:00.000000000 Z
37
37
  dependencies: []
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 4.0.3
76
+ rubygems_version: 4.0.10
77
77
  specification_version: 4
78
78
  summary: Provides whole value object behavior.
79
79
  test_files: []
metadata.gz.sig CHANGED
Binary file