foobara 0.0.46 → 0.0.48

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: 60195fb6137fde10c6e482bbdb9c6845571ba1267fbb4c3721f4f5c131b3d778
4
- data.tar.gz: 7918eb25d72cab1718160c65e0f1ed4b90c4ee70bb0ae5f44176b918d81b55f3
3
+ metadata.gz: 7c661c32185af433ba2355ce71bf37524893d00901a6e885ab5bd874339e48b6
4
+ data.tar.gz: 8ab10b8b9191bc81548d07269ca8c4906515164aa87a702ac7b944170e2420a7
5
5
  SHA512:
6
- metadata.gz: 0cc9c5ed39003bcd9b4553341a047f617287555e5000d356282a1f0438da6aacbb876db56c3464590bde0b43998af2969ad14715edfc2562a00d3d2557ce20e5
7
- data.tar.gz: 0aa89dab1a24bdf943e7caec711caa1ffec58f6769a0d543a97b2a7e839c82cd9559a90e6d9e2f4e51895f862ed3cfa7bbeff19eadb43977a2081359a465dd1f
6
+ metadata.gz: 3aaff8aa022ea5cf95ab300430576fbf08d813ccd2344630b035bf54372826fda4de76e5b7d9937e70278fcc7b0c23973d4499be25ad1531401b8b82004c153a
7
+ data.tar.gz: ffbc1887647b08588f218798cb99ab27af30ece05d4540926cb521a429c3dc9a4d992163802528f9f3a8022a52558e5158ee4b5b13dbe297a2e6036393ec49dd
data/CHANGELOG.md CHANGED
@@ -1,8 +1,11 @@
1
- ## [0.0.46] - 2025-01-03
1
+ ## [0.0.48] - 2025-01-17
2
+
3
+ - Add support for foobara_attributes_type to allow ActiveRecordType gem to work
4
+
5
+ ## [0.0.47] - 2025-01-03
2
6
 
3
7
  - Bumped Ruby from 3.2.2 to 3.4.1
4
8
  - Allow passing in a module when registering a "builtin" type
5
- - Fix AttributesHandlerDesugarizer and PrimaryKeyDesugarizer bugs
6
9
 
7
10
  ## [0.0.42] - 2024-12-23
8
11
 
@@ -91,7 +91,7 @@ module Foobara
91
91
 
92
92
  error_class = self.class.lookup_input_error_class(symbol, path)
93
93
  error_class.new(**error_args, path:)
94
- elsif args.size == 2 || args.size == 3
94
+ elsif [2, 3].include?(args.size)
95
95
  input, symbol, message = args
96
96
  context = opts
97
97
 
@@ -143,7 +143,7 @@ module Foobara
143
143
 
144
144
  error_class = self.class.lookup_runtime_error_class(symbol)
145
145
  error_class.new(**error_args)
146
- elsif args.is_a?(::Array) && (args.size == 1 || args.size == 2)
146
+ elsif args.is_a?(::Array) && [1, 2].include?(args.size)
147
147
  symbol, message = args
148
148
  context = opts
149
149
 
@@ -2,6 +2,8 @@ module Foobara
2
2
  class Command
3
3
  module Concerns
4
4
  module Inputs
5
+ class UnexpectedInputValidationError < StandardError; end
6
+
5
7
  include Concern
6
8
 
7
9
  attr_reader :inputs
@@ -41,9 +43,8 @@ module Foobara
41
43
  if error.is_a?(Value::DataError)
42
44
  add_input_error(error)
43
45
  else
44
- # TODO: raise a real error
45
46
  # :nocov:
46
- raise "wtf"
47
+ raise UnexpectedInputValidationError, "Unexpected input validation error: #{error}"
47
48
  # :nocov:
48
49
  end
49
50
  end
@@ -109,6 +109,8 @@ module Foobara
109
109
  end
110
110
  end
111
111
 
112
+ # TODO: this big switch is a problem. Hard to create new types in other projects without being able
113
+ # to modify this switch. Figure out what to do.
112
114
  def construct_associations(
113
115
  type = attributes_type,
114
116
  path = DataPath.new,
@@ -135,7 +137,12 @@ module Foobara
135
137
  construct_associations(element_type, path.append(attribute_name), result)
136
138
  end
137
139
  elsif type.extends?(BuiltinTypes[:model])
138
- construct_associations(type.target_class.attributes_type, path, result)
140
+ target_class = type.target_class
141
+
142
+ method = target_class.respond_to?(:foobara_attributes_type) ? :foobara_attributes_type : :attributes_type
143
+ attributes_type = target_class.send(method)
144
+
145
+ construct_associations(attributes_type, path, result)
139
146
  elsif type.extends?(BuiltinTypes[:associative_array])
140
147
  # not going to bother testing this for now
141
148
  # :nocov:
@@ -4,11 +4,9 @@ module Foobara
4
4
  class ExtendDetachedEntityTypeDeclaration < ExtendModelTypeDeclaration
5
5
  class PrimaryKeyDesugarizer < Desugarizer
6
6
  def applicable?(sugary_type_declaration)
7
- if sugary_type_declaration.is_a?(::Hash)
8
- primary_key = sugary_type_declaration[:primary_key]
7
+ primary_key = sugary_type_declaration[:primary_key]
9
8
 
10
- primary_key.is_a?(::String)
11
- end
9
+ primary_key.is_a?(::String)
12
10
  end
13
11
 
14
12
  def desugarize(sugary_type_declaration)
@@ -53,7 +53,7 @@ module Foobara
53
53
  end
54
54
 
55
55
  def model?
56
- return false if reference == "entity" || reference == "detached_entity"
56
+ return false if %w[entity detached_entity].include?(reference)
57
57
 
58
58
  type = base_type
59
59
 
@@ -4,7 +4,7 @@ module Foobara
4
4
  class ExtendModelTypeDeclaration < ExtendRegisteredTypeDeclaration
5
5
  class AttributesHandlerDesugarizer < TypeDeclarations::Desugarizer
6
6
  def applicable?(sugary_type_declaration)
7
- sugary_type_declaration.is_a?(::Hash) && sugary_type_declaration[:type] == expected_type_symbol
7
+ sugary_type_declaration[:type] == expected_type_symbol
8
8
  end
9
9
 
10
10
  def expected_type_symbol
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.46
4
+ version: 0.0.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-03 00:00:00.000000000 Z
10
+ date: 2025-01-18 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bigdecimal