shale-builder 0.7.1 → 0.8.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/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/lib/shale/builder/nested_validations.rb +33 -11
- data/lib/shale/builder/version.rb +1 -1
- data/lib/tapioca/dsl/compilers/shale.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ee9219ef795c936cc3572d0eef8bed6c18f5dec8b16de794a931ca2dab3a3ec
|
|
4
|
+
data.tar.gz: 74a674e79493cbb9e44cea7fc37e7463fb476aaf4ce49b717bac00996c1069ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e811406ab6d236c1e226b7d1c3bc9ea2936be56befd48bae227e0a64e51ea304bc5e7baa7e73157b56826a2cb1874fe321e6842cae5a39af746126813ac97683
|
|
7
|
+
data.tar.gz: ec643d1f6f39439c7d8393b32c963ce42dbc85d0ca23e7055a738b2d02f6d575ec4178fe3b9f3a3465a8c14fc1b34fb52f3660b1b77f5e341711bb253e7cb009
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.8.0] - 2025-10-24
|
|
9
|
+
|
|
10
|
+
[Diff](https://github.com/Verseth/ruby-shale-builder/compare/v0.8.0...v0.8.1)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
- Change `Shale::Type::Value` generated type from `Object` to `T.untyped`
|
|
14
|
+
|
|
15
|
+
## [0.8.0] - 2025-10-24
|
|
16
|
+
|
|
17
|
+
[Diff](https://github.com/Verseth/ruby-shale-builder/compare/v0.7.1...v0.8.0)
|
|
18
|
+
|
|
19
|
+
### Changes
|
|
20
|
+
- Add `Shale::Builder::NestedValidations#validatable_attribute_names`, `Shale::Builder::NestedValidations#nested_attr_name_separator`, `Shale::Builder::NestedValidations#import_errors`
|
|
21
|
+
|
|
8
22
|
## [0.7.1] - 2025-10-17
|
|
9
23
|
|
|
10
24
|
[Diff](https://github.com/Verseth/ruby-shale-builder/compare/v0.7.0...v0.7.1)
|
data/Gemfile.lock
CHANGED
|
@@ -31,44 +31,66 @@ module Shale
|
|
|
31
31
|
@nested_attr_name_separator = '.'
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
#: -> Hash[Symbol, Shale::Attribute]
|
|
35
35
|
def validatable_attributes
|
|
36
36
|
@validatable_attributes ||= attributes.select do |_, val|
|
|
37
37
|
val.validatable?
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
#: -> Array[Symbol]
|
|
42
|
+
def validatable_attribute_names
|
|
43
|
+
validatable_attribute_names.keys
|
|
44
|
+
end
|
|
40
45
|
end
|
|
41
46
|
mixes_in_class_methods ClassMethods
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
#: -> Array[Symbol]
|
|
49
|
+
def validatable_attribute_names
|
|
50
|
+
self.class.validatable_attribute_names
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
#: -> String
|
|
54
|
+
def nested_attr_name_separator
|
|
55
|
+
self.class.nested_attr_name_separator
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
#: -> bool
|
|
44
59
|
def valid?
|
|
45
60
|
result = super
|
|
46
|
-
errlist = errors
|
|
47
|
-
klass = self.class #: as untyped
|
|
48
|
-
separator = klass.nested_attr_name_separator
|
|
49
61
|
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
validatable_attribute_names.each_key do |name|
|
|
63
|
+
next unless name
|
|
64
|
+
|
|
52
65
|
val = public_send(name)
|
|
53
66
|
next unless val
|
|
54
67
|
next if val.valid?
|
|
55
68
|
|
|
56
69
|
result = false
|
|
57
|
-
val
|
|
58
|
-
errlist.import(err, attribute: "#{name}#{separator}#{err.attribute}")
|
|
59
|
-
end
|
|
70
|
+
import_errors(val)
|
|
60
71
|
end
|
|
61
72
|
|
|
62
73
|
result
|
|
63
74
|
end
|
|
64
75
|
|
|
76
|
+
#: (ActiveModel::Validations?) -> void
|
|
77
|
+
def import_errors(obj)
|
|
78
|
+
return unless obj
|
|
79
|
+
|
|
80
|
+
errlist = errors
|
|
81
|
+
separator = nested_attr_name_separator
|
|
82
|
+
obj.errors.each do |err|
|
|
83
|
+
errlist.import(err, attribute: "#{name}#{separator}#{err.attribute}")
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
65
87
|
end
|
|
66
88
|
end
|
|
67
89
|
end
|
|
68
90
|
|
|
69
91
|
module Shale
|
|
70
92
|
class Attribute # rubocop:disable Style/Documentation
|
|
71
|
-
|
|
93
|
+
#: -> bool
|
|
72
94
|
def validatable?
|
|
73
95
|
Boolean(type.is_a?(Class) && type < ::ActiveModel::Validations)
|
|
74
96
|
end
|
|
@@ -156,7 +156,7 @@ module Tapioca
|
|
|
156
156
|
# Maps Shale return types to Sorbet types
|
|
157
157
|
SHALE_RETURN_TYPES_MAP = T.let(
|
|
158
158
|
{
|
|
159
|
-
::Shale::Type::Value =>
|
|
159
|
+
::Shale::Type::Value => T.untyped,
|
|
160
160
|
::Shale::Type::String => String,
|
|
161
161
|
::Shale::Type::Float => Float,
|
|
162
162
|
::Shale::Type::Integer => Integer,
|
|
@@ -172,7 +172,7 @@ module Tapioca
|
|
|
172
172
|
# Maps Shale setter types to Sorbet types
|
|
173
173
|
SHALE_SETTER_TYPES_MAP = T.let(
|
|
174
174
|
{
|
|
175
|
-
::Shale::Type::Value =>
|
|
175
|
+
::Shale::Type::Value => T.untyped,
|
|
176
176
|
::Shale::Type::String => String,
|
|
177
177
|
::Shale::Type::Float => Float,
|
|
178
178
|
::Shale::Type::Integer => Integer,
|