wholable 0.1.1 → 0.2.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: 72a28b3df96aec9ab54375e96583424bc919c9659b2f701ab600b341d82d61b9
4
- data.tar.gz: 898361fe5766c92fc629b7ea3d459576a902369f09fe438f3c7e5cc76ed93bf3
3
+ metadata.gz: c640d1b445b6096abc2a6f8fbf24dcefc9f8a6494f142ff62537049e0ae9277b
4
+ data.tar.gz: 4842eb59866f915c2b0aaec48831fe4202d81ba61b4a37447d7f4a053463429d
5
5
  SHA512:
6
- metadata.gz: a66ba09ec485373c4b3789203bf5a5d72d4d5438d33668f4981de9269b665ccbd81a5969f45da443149a377775762090d9926e826648b9a5f5fb5c7f72fc3d36
7
- data.tar.gz: e0407f928f8310c4350a512ee087ab8c542ca66482cd2f2fc67c9cd996b4991aa53ac3c8ab2209c57429108b1ed743afb5f76b9ec43fc63249e0e7055e3bef0a
6
+ metadata.gz: fce0c37d6e2d8cc06ecc9c3872f2dce96d133691c5fa5e9cc8a22dc2b013320827500b3b7b6456e15cf3282bda710f9c2b1b79c9c86bdbd4f1b2406719caa667
7
+ data.tar.gz: 64dcd589d044dd9368462ce6f8f4191d722b9f44952616574d2fde46abf602d57332dcaa7f5fd1852dfabf5eccc1279703163619938c8914e5b0863d9461fffb
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -130,8 +130,8 @@ As you can see, object equality is determined by the object's values and _not_ b
130
130
 
131
131
  . The corresponding _public_ `attr_reader` for each key is created which saves you time and reduces double entry when implementing your whole value object.
132
132
  . The `#to_a` and `#to_h` methods are added for convenience in order to play nice with {data_link} and {structs_link}.
133
- . The `#deconstruct` and `#deconstruct_keys` aliases are created for you so you can leverage {pattern_matching_link}.
134
- . Custom `#==`, `#eql?`, `#hash`, `#inspect`, `#to_a`, `#to_h`, and `#with` methods are added to provide whole value behavior.
133
+ . The `#deconstruct` and `#deconstruct_keys` aliases are created so you can leverage {pattern_matching_link}.
134
+ . The `#==`, `#eql?`, `#hash`, `#inspect`, and `#with` methods are added to provide whole value behavior.
135
135
  . The object is immediately frozen after initialization to ensure your instance is _immutable_ by default.
136
136
 
137
137
  == Caveats
@@ -6,14 +6,5 @@ module Wholable
6
6
  def eql?(other) = instance_of?(other.class) && hash == other.hash
7
7
 
8
8
  def ==(other) = other.is_a?(self.class) && hash == other.hash
9
-
10
- def diff other
11
- if other.is_a? self.class
12
- to_h.merge(other.to_h) { |_, one, two| [one, two].uniq }
13
- .select { |_, diff| diff.size == 2 }
14
- else
15
- to_h.each.with_object({}) { |(key, value), diff| diff[key] = [value, nil] }
16
- end
17
- end
18
9
  end
19
10
  end
@@ -27,6 +27,7 @@ module Wholable
27
27
  define_with
28
28
  define_to_a
29
29
  define_to_h
30
+ define_diff
30
31
  end
31
32
 
32
33
  def define_class_methods descendant
@@ -95,5 +96,16 @@ module Wholable
95
96
  local_keys.each.with_object({}) { |key, dictionary| dictionary[key] = public_send key }
96
97
  end
97
98
  end
99
+
100
+ def define_diff
101
+ define_method :diff do |other|
102
+ if other.is_a? self.class
103
+ to_h.merge!(other.to_h) { |_, one, two| [one, two].uniq }
104
+ .select { |_, diff| diff.size == 2 }
105
+ else
106
+ to_h.each.with_object({}) { |(key, value), diff| diff[key] = [value, nil] }
107
+ end
108
+ end
109
+ end
98
110
  end
99
111
  end
data/wholable.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "wholable"
5
- spec.version = "0.1.1"
5
+ spec.version = "0.2.1"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/wholable"
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.signing_key = Gem.default_key_path
23
23
  spec.cert_chain = [Gem.default_cert_path]
24
24
 
25
- spec.required_ruby_version = "~> 3.2"
25
+ spec.required_ruby_version = [">= 3.2", "<= 3.3"]
26
26
 
27
27
  spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
28
28
  spec.files = Dir["*.gemspec", "lib/**/*"]
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wholable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -35,7 +35,7 @@ cert_chain:
35
35
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
36
36
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
37
37
  -----END CERTIFICATE-----
38
- date: 2023-10-26 00:00:00.000000000 Z
38
+ date: 2023-11-16 00:00:00.000000000 Z
39
39
  dependencies: []
40
40
  description:
41
41
  email:
@@ -70,16 +70,19 @@ require_paths:
70
70
  - lib
71
71
  required_ruby_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '3.2'
76
+ - - "<="
77
+ - !ruby/object:Gem::Version
78
+ version: '3.3'
76
79
  required_rubygems_version: !ruby/object:Gem::Requirement
77
80
  requirements:
78
81
  - - ">="
79
82
  - !ruby/object:Gem::Version
80
83
  version: '0'
81
84
  requirements: []
82
- rubygems_version: 3.4.21
85
+ rubygems_version: 3.4.22
83
86
  signing_key:
84
87
  specification_version: 4
85
88
  summary: A whole value object mixin.
metadata.gz.sig CHANGED
Binary file