foobara 0.0.23 → 0.0.24

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: 17aca0016743da17a419540e3953855d94ee622a0f331fdc1e3765f02eef8772
4
- data.tar.gz: f35365045973554ca57d08107dcb645f26406cd70e69598120f234462257074b
3
+ metadata.gz: 53375c9393cbdf5594959c3233650f0cd08b78fc2bf3a07863debcdf12c4f2d9
4
+ data.tar.gz: 388d748e47be7c602bd79661f1265ecb276b290f067e7c8114231d8a8cb5319f
5
5
  SHA512:
6
- metadata.gz: 5cad819d5b7aeb1122a31a36f8ba4569d0142454be39030629d8996f60469edc6da2d555ae49c0b8513c011ad0e317de2a6696fee1de807c5c813a19a8b2f07c
7
- data.tar.gz: ab20a3c72ffa7d0ebb3e921d70bf519d4070ab076ae699743c4600b7e17e9cd1f08d0437dc27a39f141272c6a3d7e0bad824a9cda05f07a3c17b6ff7bdb1d55c
6
+ metadata.gz: 7ce8fdd0b10b5ab7935c8f41dd461be81bbcd9805ead1c81619abafb4f169bf8e38c592818da7f0a0969fde1da214ba7f718e78d70e042b3279facf4224d8c30
7
+ data.tar.gz: 72beca35aa357bb745d2fdf61b910d8aeba8f51d7fd897e1f94cba02191a41cdacf1c08ff38085da8f094d6e8bf56629bd4a607fc7a1b49ff38d162c6a7c0a5f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,6 @@
1
- ## [0.0.23] - 2024-12-03
1
+ ## [0.0.24] - 2024-12-03
2
2
 
3
+ - Allow passing all Error subclass parameters into possible_*error calls
3
4
  - Allow creating entity types from declaration without model_module
4
5
  - Make model classes with an mutable of false have instances that default to immutable
5
6
 
@@ -41,8 +41,13 @@ module Foobara
41
41
  # :nocov:
42
42
  end
43
43
  when 2
44
- symbol, error_class_or_context_type_declaration, data = args
45
- error_class = to_runtime_error_class(symbol, error_class_or_context_type_declaration)
44
+ symbol, subclass_parameters, data = args
45
+
46
+ error_class = Foobara::RuntimeError.subclass(
47
+ **subclass_parameters,
48
+ symbol:
49
+ )
50
+
46
51
  PossibleError.new(error_class, symbol:, data:)
47
52
  else
48
53
  # :nocov:
@@ -56,20 +61,18 @@ module Foobara
56
61
  def possible_input_error(
57
62
  path,
58
63
  symbol_or_error_class,
59
- error_class_or_context_type_declaration = {},
64
+ error_class_or_subclass_parameters = {},
60
65
  data = nil
61
66
  )
62
- error_class, symbol = if symbol_or_error_class.is_a?(Class)
63
- [symbol_or_error_class, symbol_or_error_class.symbol]
64
- else
65
- [
66
- to_input_error_class(
67
- symbol_or_error_class,
68
- error_class_or_context_type_declaration
69
- ),
70
- symbol_or_error_class
71
- ]
72
- end
67
+ error_class = if symbol_or_error_class.is_a?(Class)
68
+ symbol_or_error_class
69
+ else
70
+ Foobara::DataError.subclass(
71
+ **error_class_or_subclass_parameters, symbol: symbol_or_error_class
72
+ )
73
+ end
74
+
75
+ symbol = error_class.symbol
73
76
 
74
77
  possible_error = PossibleError.new(error_class, symbol:, data:)
75
78
  possible_error.prepend_path!(path)
@@ -102,21 +105,6 @@ module Foobara
102
105
  key = possible_error.key.to_s
103
106
  error_context_type_map.delete(key)
104
107
  end
105
-
106
- # TODO: should we cache these???
107
- def to_input_error_class(symbol, context_type_declaration)
108
- Foobara::Value::DataError.subclass(
109
- symbol:,
110
- context_type_declaration:
111
- )
112
- end
113
-
114
- def to_runtime_error_class(symbol, context_type_declaration)
115
- Foobara::RuntimeError.subclass(
116
- symbol:,
117
- context_type_declaration:
118
- )
119
- end
120
108
  end
121
109
  end
122
110
  end
@@ -93,7 +93,7 @@ module Foobara
93
93
 
94
94
  def subclass(
95
95
  # TODO: technically context_type_declaration doesn't belong here. But maybe it should.
96
- context_type_declaration:,
96
+ context: {},
97
97
  name: nil,
98
98
  symbol: nil,
99
99
  message: nil,
@@ -120,7 +120,7 @@ module Foobara
120
120
  end
121
121
 
122
122
  singleton_class.define_method :context_type_declaration do
123
- context_type_declaration
123
+ context
124
124
  end
125
125
 
126
126
  if message
@@ -24,4 +24,6 @@ module Foobara
24
24
  end
25
25
  end
26
26
  end
27
+
28
+ DataError = Value::DataError
27
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi