foobara 0.0.108 → 0.0.110

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: a6229c57edc14afe9facb9e97af267fcd15e451ee8bf2acef8570eb6c5ec10e4
4
- data.tar.gz: 2a7df403a2735b6c6f539bfad23c95d211e90d40c01bead9390060655a1c7f1b
3
+ metadata.gz: 71a254889aa452b7a219cb8d9b4c7d1c2eb2c21ea452ae783e62d601720c387b
4
+ data.tar.gz: 451cf0735d2c75026c92b92381e0e8a3766ed69a8a08eed739e6866e88f5b134
5
5
  SHA512:
6
- metadata.gz: 79936bf327a870ac068df58619239b36e79ef48bf75263feba30a67c16e01202757d0d7428851cfb0c8234cc60ed8454f4a41ce61da8f027bd49a5236c6bf4d4
7
- data.tar.gz: 624175000edf49d2188a15a8b418d3927b757660c6637fe8916a6a87a6d3793aef5db2ae0985f7892327910eae872c0ecfed55bde53caaf416b0f490de11d6f0
6
+ metadata.gz: 6d758bae9e990d477c7775966b69dd1a51ae1878b938fec278a76ebbb8dd88a417e6c68f3a11174929cb86f858294bf1207206704bba70c458035e3798b12597
7
+ data.tar.gz: 9f7c770b990f942884aaa79f45f7ce344aaabaa8a939536d869802c25ccc2ada3b7ddb476119a543d5546019874ae44929af29d5437d0574e447a4f8acc398ed
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [0.0.110] - 2025-04-23
2
+
3
+ - Automatically load associations needed for delegated attributes for
4
+ result of commands exposed via command connectors
5
+
6
+ # [0.0.109] - 2025-04-22
7
+
8
+ - Support CommandConnector transformers that don't take declaration_data
9
+
1
10
  # [0.0.108] - 2025-04-22
2
11
 
3
12
  - Fix bug in CommandConnector::NotFoundError constructor
@@ -424,7 +424,8 @@ module Foobara
424
424
  target_type = new_type if new_type
425
425
  end
426
426
  else
427
- transformer.new(declaration_data)
427
+ # TODO: perhaps pass in the command connector as the parent declaration data?
428
+ transformer.new_with_agnostic_args(declaration_data:)
428
429
  end
429
430
  elsif transformer.is_a?(Value::Processor)
430
431
  transformer
@@ -1,14 +1,14 @@
1
1
  module Foobara
2
2
  class CommandConnector
3
3
  class Authenticator
4
- attr_accessor :block, :explanation, :symbol
4
+ attr_reader :block, :explanation, :symbol
5
5
 
6
6
  def initialize(symbol: nil, explanation: nil, &block)
7
7
  symbol ||= Util.non_full_name_underscore(self.class).to_sym
8
8
 
9
- self.symbol = symbol
10
- self.block = block
11
- self.explanation = explanation || symbol
9
+ @symbol = symbol
10
+ @block = block
11
+ @explanation = explanation || symbol
12
12
  end
13
13
 
14
14
  def to_proc
@@ -36,13 +36,14 @@ module Foobara
36
36
 
37
37
  unless authenticator.symbol
38
38
  # :nocov:
39
- raise ArgumentError, "Expected an authenticator to have a symbol"
39
+ raise ArgumentError, "Expected authenticator to have a symbol"
40
40
  # :nocov:
41
41
  end
42
42
 
43
43
  authenticator_registry[authenticator.symbol] = authenticator
44
44
  end
45
45
 
46
+ # TODO: relocate to Authenticator
46
47
  def to_authenticator(*args)
47
48
  symbol, object = case args.size
48
49
  when 1
@@ -90,6 +90,22 @@ module Foobara
90
90
  self.allowed_rule = allowed_rule
91
91
  self.requires_authentication = requires_authentication
92
92
  self.authenticator = authenticator
93
+
94
+ # A bit hacky... we should check if we need to shim in a LoadDelegatedAttributesEntitiesPreCommitTransformer
95
+ unless aggregate_entities
96
+ # It's possible delegates have been added or removed via the result transformers...
97
+ # We should figure out a way to check the transformed result type instead.
98
+ if _has_delegated_attributes?(command_class.result_type)
99
+ self.pre_commit_transformers = [
100
+ *self.pre_commit_transformers,
101
+ CommandConnectors::Transformers::LoadDelegatedAttributesEntitiesPreCommitTransformer
102
+ ].uniq
103
+ end
104
+ end
105
+ end
106
+
107
+ def _has_delegated_attributes?(type)
108
+ type&.extends?(BuiltinTypes[:model]) && type.target_class&.has_delegated_attributes?
93
109
  end
94
110
 
95
111
  def full_command_name
@@ -155,6 +155,10 @@ module Foobara
155
155
  @delegates ||= {}
156
156
  end
157
157
 
158
+ def has_delegated_attributes?
159
+ !delegates.empty?
160
+ end
161
+
158
162
  def private_attribute_names
159
163
  @private_attribute_names ||= []
160
164
  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.108
4
+ version: 0.0.110
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -508,7 +508,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
508
508
  - !ruby/object:Gem::Version
509
509
  version: '0'
510
510
  requirements: []
511
- rubygems_version: 3.6.7
511
+ rubygems_version: 3.6.8
512
512
  specification_version: 4
513
513
  summary: A command-centric and discoverable software framework with a focus on domain
514
514
  concepts and abstracting away integration code