shale-builder 0.7.1 → 0.8.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: 47c398fb41a4f4a4b2739aa542a822e2979c36ed7373dede2551d639116b2c8a
4
- data.tar.gz: 39c4d99b27828c05d9bf92afe73622e681ea53cf8d5350b6ea6fb13358f46554
3
+ metadata.gz: 1bc4050027c07ff6a3bf24b27df89131835ebe1cf9beb9d53bc1277809616a27
4
+ data.tar.gz: 109df45cbb2687a06e08fcc9baa153c2a813410cc009a730c1453672031e0387
5
5
  SHA512:
6
- metadata.gz: bba9c31eec3c19efa1866a9295b7c625410e600fd4051fecfd4eb150c26d2b955dcbb64117eb6d0d78783b134d4f203a7c225e5a97a1c247abbcbbf1e48652ee
7
- data.tar.gz: 27e186c186770c0c5fd7e6f62efb141b2ba1d71f26ec8eb127659253c7ce7f936e0cd56f325050132e4e96ea74471df16804d7b61704852d32c8154ca93b8fd0
6
+ metadata.gz: 0b363fdf655cb8aec7a996f9dee375e8116aaed816a28e112acdaba2413cdbc902f32915f8670cffc92caec08042b8a0bd90c4e80c996d58ee7b9a0bcff07f95
7
+ data.tar.gz: 93ffb3fa8e767cab76bb9ad84492fd4fb581b1345fe2614964f4f63a5ba4b107c5928892c16edb8794288d49bcd9b8097321be904da7628d09ec9934c2709c00
data/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ 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.7.1...v0.8.0)
11
+
12
+ ### Changes
13
+ - Add `Shale::Builder::NestedValidations#validatable_attribute_names`, `Shale::Builder::NestedValidations#nested_attr_name_separator`, `Shale::Builder::NestedValidations#import_errors`
14
+
8
15
  ## [0.7.1] - 2025-10-17
9
16
 
10
17
  [Diff](https://github.com/Verseth/ruby-shale-builder/compare/v0.7.0...v0.7.1)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shale-builder (0.7.1)
4
+ shale-builder (0.8.0)
5
5
  booleans (>= 0.1)
6
6
  shale (< 2.0)
7
7
  sorbet-runtime (> 0.5)
@@ -31,44 +31,66 @@ module Shale
31
31
  @nested_attr_name_separator = '.'
32
32
  end
33
33
 
34
- sig { returns(T::Hash[Symbol, Shale::Attribute]) }
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
- sig { returns(T::Boolean) }
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
- attrs = T.unsafe(self).class.validatable_attributes
51
- attrs.each_key do |name|
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.errors.each do |err|
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
- sig { returns(T::Boolean) }
93
+ #: -> bool
72
94
  def validatable?
73
95
  Boolean(type.is_a?(Class) && type < ::ActiveModel::Validations)
74
96
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Shale
4
4
  module Builder
5
- VERSION = '0.7.1'
5
+ VERSION = '0.8.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shale-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Drewniak