lab42_data_class 0.7.0 → 0.7.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/README.md +1 -3
- data/lib/lab42/data_class/proxy/constraints.rb +2 -2
- data/lib/lab42/data_class/proxy/memos.rb +4 -0
- data/lib/lab42/data_class/proxy.rb +1 -1
- data/lib/lab42/data_class/undefined_attribute_error.rb +9 -0
- data/lib/lab42/data_class/version.rb +1 -1
- data/lib/lab42/data_class.rb +1 -0
- 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: 8fdfa61b721a7e006b42dd59c3dc61c4f3442faaa0d50feeaa5ed4b20ea5838c
|
4
|
+
data.tar.gz: fa5d7ab0e6133c398caaaa1762e75a5820123e67088acc4750c36e9246ff2dc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53af67931648a621cd0ff18912ce191dc2d0a005eacfd4df741bbdf8a58a9c695e168055129c76be08efcb4810d3910a5df362512996c8d2375da6ff17b61be8
|
7
|
+
data.tar.gz: c65a655f447f154b1a4e7584393fe3058403ef53cf5651a51fd39e5af7ebbd88768e90dc9b8d1a7d582316a35d2786abff6c6a04cc2f445f8d725657773c9a21
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
|
2
|
-
|
3
2
|
[](https://codeclimate.com/github/RobertDober/lab42_data_class)
|
4
3
|
[](https://github.com/robertdober/lab42_data_class/actions)
|
5
4
|
[](https://coveralls.io/github/RobertDober/lab42_data_class?branch=main)
|
@@ -9,7 +8,6 @@
|
|
9
8
|
|
10
9
|
# Lab42::DataClass
|
11
10
|
|
12
|
-
|
13
11
|
An Immutable DataClass for Ruby
|
14
12
|
|
15
13
|
Exposes a class factory function `Kernel::DataClass` and a module `Lab42::DataClass` which can
|
@@ -41,7 +39,7 @@ Therefore we can summarise the features (or not so features, that is for you to
|
|
41
39
|
## Usage
|
42
40
|
|
43
41
|
```sh
|
44
|
-
gem install lab42_data_class
|
42
|
+
gem install lab42_data_class
|
45
43
|
```
|
46
44
|
|
47
45
|
With bundler
|
@@ -14,7 +14,7 @@ module Lab42
|
|
14
14
|
|
15
15
|
def define_constraint
|
16
16
|
->((attr, constraint)) do
|
17
|
-
if members
|
17
|
+
if members!.member?(attr)
|
18
18
|
constraints[attr] << Maker.make_constraint(constraint)
|
19
19
|
nil
|
20
20
|
else
|
@@ -26,7 +26,7 @@ module Lab42
|
|
26
26
|
def define_constraints(constraints)
|
27
27
|
errors = constraints.map(&define_constraint).compact
|
28
28
|
unless errors.empty?
|
29
|
-
raise
|
29
|
+
raise UndefinedAttributeError,
|
30
30
|
"constraints cannot be defined for undefined attributes #{errors.inspect}"
|
31
31
|
end
|
32
32
|
|
@@ -54,7 +54,7 @@ module Lab42
|
|
54
54
|
positionals.delete(name)
|
55
55
|
defaults.delete(name)
|
56
56
|
derived_attributes.update(name => true) do |_key, _old,|
|
57
|
-
raise DuplicateDefinitionError, "Redefinition of derived attribute #{name}"
|
57
|
+
raise DuplicateDefinitionError, "Redefinition of derived attribute #{name.inspect}"
|
58
58
|
end
|
59
59
|
klass.module_eval(&_define_derived_attribute(name, &blk))
|
60
60
|
end
|
data/lib/lab42/data_class.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative './data_class/constraint_error'
|
4
4
|
require_relative './data_class/duplicate_definition_error'
|
5
5
|
require_relative './data_class/kernel'
|
6
|
+
require_relative './data_class/undefined_attribute_error'
|
6
7
|
require_relative './data_class/validation_error'
|
7
8
|
require_relative './data_class/proxy'
|
8
9
|
require_relative './pair'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab42_data_class
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
An Immutable DataClass for Ruby
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/lab42/data_class/proxy/memos.rb
|
35
35
|
- lib/lab42/data_class/proxy/mixin.rb
|
36
36
|
- lib/lab42/data_class/proxy/validations.rb
|
37
|
+
- lib/lab42/data_class/undefined_attribute_error.rb
|
37
38
|
- lib/lab42/data_class/validation_error.rb
|
38
39
|
- lib/lab42/data_class/version.rb
|
39
40
|
- lib/lab42/eq_and_patterns.rb
|