foobara 0.0.26 → 0.0.27

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: 74ed1cc03610fe5533258dc181f0874db18119716a193820aa3b227c4c70646f
4
- data.tar.gz: 30f4d98511c5842e55b66a184952b19514dab9a18b0a86d14c4a708becaa758f
3
+ metadata.gz: 463e274d4eb6227cdf473fc12bab4a7519db226c07f458c7bd04e8a9f84f1440
4
+ data.tar.gz: bfaaf65911fb2c87363ea619f58ea042b1236653797d11ab9c59793f83b26d34
5
5
  SHA512:
6
- metadata.gz: 8d4fc1f0de283351f4aeefbf8467c3fe77a66122e7621db77a086578ee4958cf0402ef158781ca1790326ad94d8dd1f8f5ff1f773ce3e6f1b3d393ef9313a0bc
7
- data.tar.gz: c79c5217ae9463cf8139d065165f5c7e3508eedbd21a468c4d3e9059f49754c16fde5352cbd2f4a6ad55faa6a7a866a1db6e436dc24820831da14e431c0edbb1
6
+ metadata.gz: 34f1340468762419907715d77f6f98e13ee551b645bc94c258984458dd2120ed5e607f8ea6148f5fdda3f53ceae1ad981bf82a522060bae948869119b309fa45
7
+ data.tar.gz: 945c3807af1fdf55aab4e87bc635abfc8ee1bec12ff5458ee5c4336a71174f5671f768e87daa72bfc97178ad10a9ebefc3b93757a9afd8d276ee50f5bc2202b8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.0.27] - 2024-12-04
2
+
3
+ - Add some Error DSL convenience methods (symbol/message/context)
4
+
1
5
  ## [0.0.26] - 2024-12-03
2
6
 
3
7
  - Add error defaults for message and context
@@ -18,8 +18,22 @@ module Foobara
18
18
  @abstract
19
19
  end
20
20
 
21
- def symbol
22
- Util.non_full_name_underscore(self).gsub(/_error$/, "").to_sym
21
+ def symbol(*args)
22
+ args_size = args.size
23
+
24
+ case args_size
25
+ when 0
26
+ Util.non_full_name_underscore(self).gsub(/_error$/, "").to_sym
27
+ when 1
28
+ arg = args.first
29
+ singleton_class.define_method :symbol do
30
+ arg
31
+ end
32
+ else
33
+ # :nocov:
34
+ raise ArgumentError, "expected 0 or 1 argument, got #{args_size}"
35
+ # :nocov:
36
+ end
23
37
  end
24
38
 
25
39
  # Is this actually used?
@@ -35,12 +49,40 @@ module Foobara
35
49
  nil
36
50
  end
37
51
 
38
- def message
39
- Util.humanize(symbol.to_s)
52
+ def message(*args)
53
+ args_size = args.size
54
+
55
+ case args_size
56
+ when 0
57
+ Util.humanize(symbol.to_s)
58
+ when 1
59
+ arg = args.first
60
+ singleton_class.define_method :message do
61
+ arg
62
+ end
63
+ else
64
+ # :nocov:
65
+ raise ArgumentError, "expected 0 or 1 argument, got #{args_size}"
66
+ # :nocov:
67
+ end
40
68
  end
41
69
 
42
- def context
43
- nil
70
+ def context(*args)
71
+ args_size = args.size
72
+
73
+ case args_size
74
+ when 0
75
+ {}
76
+ when 1
77
+ arg = args.first
78
+ singleton_class.define_method :context_type_declaration do
79
+ arg
80
+ end
81
+ else
82
+ # :nocov:
83
+ raise ArgumentError, "expected 0 or 1 argument, got #{args_size}"
84
+ # :nocov:
85
+ end
44
86
  end
45
87
 
46
88
  def fatal?
@@ -92,7 +134,7 @@ module Foobara
92
134
  end
93
135
 
94
136
  def subclass(
95
- # TODO: technically context_type_declaration doesn't belong here. But maybe it should.
137
+ # TODO: technically context doesn't belong here. But maybe it should.
96
138
  context: {},
97
139
  name: nil,
98
140
  symbol: nil,
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.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi