wholable 0.1.1 → 0.2.0

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: 126369e88f3d51122002ebcd4de0cff80f95ad961fc0cd57f1f49e67419f7df7
4
+ data.tar.gz: c237212bd075a6d6ee075367664a9161e82dd483db94c6d69aeb2f6b65fa9283
5
5
  SHA512:
6
- metadata.gz: a66ba09ec485373c4b3789203bf5a5d72d4d5438d33668f4981de9269b665ccbd81a5969f45da443149a377775762090d9926e826648b9a5f5fb5c7f72fc3d36
7
- data.tar.gz: e0407f928f8310c4350a512ee087ab8c542ca66482cd2f2fc67c9cd996b4991aa53ac3c8ab2209c57429108b1ed743afb5f76b9ec43fc63249e0e7055e3bef0a
6
+ metadata.gz: 439990b25f13e9a144b5e3c1e8487ce78bd43ee7dfe44c1ee35018ad4c13dc242ec633b1fb786c37ad95dd96b439ca0508fff502c764f1ae4c88b4550053252c
7
+ data.tar.gz: 17d4ddbcdfcaef66aefed5c2e5018cbb34b6c4efd4c7953b026d0d7ed3b2d03bb7aa04a33f620f6222fe9b735329af027c2dab5ef47dae1eacccb6f84ae97381
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.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/wholable"
data.tar.gz.sig CHANGED
@@ -1,4 +1 @@
1
- _Np�a�8�&4G3�m6���Ejj����#G��B�������i傺IM̈́{ ���Ħ�c ����<�o�����
2
- ���IR���/��A��
3
- G�ͭ36Ғ[���6͋��VF��.�Q~W��% ����G�Y�fh��Li+���u&�b|6$�JYx�)a�v���A��_j��Ӭ"Ey��8a�Lў+��|K��/��(#u$B�� �u�Z~�p�&
4
- C3���B�~�2��0���s�,FC��~�
1
+ ��v\�����CM���G3V�_$p: �@/�_8a���Bp���4����H�����X����q���:�D70YM��x�����G
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.0
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-04 00:00:00.000000000 Z
39
39
  dependencies: []
40
40
  description:
41
41
  email:
metadata.gz.sig CHANGED
Binary file