foobara 0.0.110 → 0.0.112

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: 71a254889aa452b7a219cb8d9b4c7d1c2eb2c21ea452ae783e62d601720c387b
4
- data.tar.gz: 451cf0735d2c75026c92b92381e0e8a3766ed69a8a08eed739e6866e88f5b134
3
+ metadata.gz: a36c133c68acf0ea569d20a21409921f0c5dfe0e147c830f2572b84bda6d77b2
4
+ data.tar.gz: e0e44b5fb75ab902e32b8200ef8a19420f1aaee94f8786c6af63731463e78318
5
5
  SHA512:
6
- metadata.gz: 6d758bae9e990d477c7775966b69dd1a51ae1878b938fec278a76ebbb8dd88a417e6c68f3a11174929cb86f858294bf1207206704bba70c458035e3798b12597
7
- data.tar.gz: 9f7c770b990f942884aaa79f45f7ce344aaabaa8a939536d869802c25ccc2ada3b7ddb476119a543d5546019874ae44929af29d5437d0574e447a4f8acc398ed
6
+ metadata.gz: f2d7343f12f57901d9d60c9ef419e35938bf77e2a9552ea0ef095d33cd07fd0f648d9d8f78698842c94ffb0fcc447fbe1a64ea62d5d5ae5569ea0c127fba8d60
7
+ data.tar.gz: 97edd6f9217b2fd7651f72643671ad7ce191772d6472f4a1715eb66ca93506181c43614ddef6c3405de3f579d9765e5a135ce0383e5547a19b1b7e21faead8a8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # [0.0.112] - 2025-04-25
2
+
3
+ - Fix bugs preventing generating manifest for connector with mutator instances instead of classes
4
+
5
+ # [0.0.111] - 2025-04-25
6
+
7
+ - Fix bug in DomainMapper.depends_on
8
+ - Allow mutator instances to be used by connectors not just classes
9
+ - Some WeakObjectSet tweaks
10
+
1
11
  # [0.0.110] - 2025-04-23
2
12
 
3
13
  - Automatically load associations needed for delegated attributes for
@@ -59,7 +59,8 @@ module Foobara
59
59
  if subcommand_classes.empty?
60
60
  return @depends_on if defined?(@depends_on)
61
61
 
62
- @depends_on = if self == Foobara::Command
62
+ # TODO: get Command and DomainMapper out of here!
63
+ @depends_on = if self == Foobara::Command || self == Foobara::DomainMapper
63
64
  Set.new
64
65
  else
65
66
  superclass.depends_on.dup
@@ -122,8 +122,14 @@ module Foobara
122
122
 
123
123
  mutated_result_type = result_type
124
124
 
125
- response_mutators&.reverse&.each do |mutator|
126
- mutated_result_type = mutator.instance.result_type_from(mutated_result_type)
125
+ mutators = if response_mutators.size == 1
126
+ [response_mutator]
127
+ else
128
+ response_mutator&.processors&.reverse
129
+ end
130
+
131
+ mutators&.each do |mutator|
132
+ mutated_result_type = mutator.result_type_from(mutated_result_type)
127
133
  end
128
134
 
129
135
  @result_type_for_manifest = mutated_result_type
@@ -134,8 +140,14 @@ module Foobara
134
140
 
135
141
  mutated_inputs_type = inputs_type
136
142
 
137
- request_mutators&.each do |mutator|
138
- mutated_inputs_type = mutator.instance.inputs_type_from(mutated_inputs_type)
143
+ mutators = if request_mutators.size == 1
144
+ [request_mutator]
145
+ else
146
+ request_mutator&.processors&.reverse
147
+ end
148
+
149
+ mutators&.each do |mutator|
150
+ mutated_inputs_type = mutator.inputs_type_from(mutated_inputs_type)
139
151
  end
140
152
 
141
153
  @inputs_type_for_manifest = mutated_inputs_type
@@ -284,10 +296,8 @@ module Foobara
284
296
  end
285
297
  end
286
298
 
287
- response_mutators = self.response_mutators.map(&:foobara_manifest)
288
- request_mutators = TypeDeclarations.with_manifest_context(remove_sensitive: false) do
289
- self.request_mutators.map(&:foobara_manifest)
290
- end
299
+ response_mutators = mutators_to_manifest_symbols(self.response_mutators, to_include:)
300
+ request_mutators = mutators_to_manifest_symbols(self.request_mutators, to_include:)
291
301
 
292
302
  authenticator_manifest = if authenticator
293
303
  if authenticator.respond_to?(:foobara_manifest)
@@ -333,6 +343,42 @@ module Foobara
333
343
  )
334
344
  end
335
345
 
346
+ def mutators_to_manifest_symbols(mutators, to_include:)
347
+ return nil if mutators.nil? || mutators.empty?
348
+
349
+ mutators.map do |mutator|
350
+ if mutator.scoped_path_set?
351
+ to_include << mutator
352
+ mutator.foobara_manifest_reference
353
+ elsif mutator.is_a?(Value::Mutator)
354
+ klass = mutator.class
355
+
356
+ if klass.scoped_path_set?
357
+ to_include << klass
358
+ klass.foobara_manifest_reference
359
+ # TODO: Delete this nocov block
360
+ # TODO: make anonymous scoped path's have better names instead of random hexadecimal
361
+ # :nocov:
362
+ elsif mutator.symbol
363
+ mutator.symbol
364
+ else
365
+
366
+ to_include << klass if klass.scoped_path_set?
367
+
368
+ name = klass.name
369
+
370
+ while name.nil?
371
+ klass = klass.superclass
372
+ name = klass.name
373
+ end
374
+
375
+ "Anonymous#{Util.non_full_name(name)}"
376
+ # :nocov:
377
+ end
378
+ end
379
+ end
380
+ end
381
+
336
382
  def inputs_transformer
337
383
  return @inputs_transformer if defined?(@inputs_transformer)
338
384
 
@@ -64,9 +64,6 @@ module Foobara
64
64
  end
65
65
 
66
66
  def updated(record)
67
- # Hacky way to handle situation where the primary key might have changed.
68
- # TODO: make a better way of handling this.
69
- tracked_records.delete(record)
70
67
  tracked_records << record
71
68
 
72
69
  # TODO: is this check redundant? Maybe have the entity explode directly instead?
@@ -519,8 +519,6 @@ module Foobara
519
519
 
520
520
  def flush_created!
521
521
  marked_created.each do |record|
522
- tracked_records.delete(record)
523
-
524
522
  flush_created_associations!(record)
525
523
 
526
524
  # TODO: do this in bulk
@@ -540,8 +538,6 @@ module Foobara
540
538
  end
541
539
 
542
540
  def flush_created_record!(record)
543
- tracked_records.delete(record)
544
-
545
541
  flush_created_associations!(record)
546
542
 
547
543
  unmark_created(record)
@@ -97,22 +97,40 @@ module Foobara
97
97
  end
98
98
 
99
99
  def <<(object)
100
- garbage_cleaner.track(object)
101
-
102
100
  object_id = object.object_id
103
101
 
104
- objects[object_id] = WeakRef.new(object)
102
+ if include?(object)
103
+ if @key_method
104
+ key = object.send(@key_method)
105
+ old_key = object_id_to_key[object_id]
105
106
 
106
- if @key_method
107
- key = object.send(@key_method)
107
+ if key != old_key
108
+ key_to_object_id.delete(old_key)
108
109
 
109
- if key
110
- key_to_object_id[key] = object_id
111
- object_id_to_key[object_id] = key
110
+ if key
111
+ key_to_object_id[key] = object_id
112
+ object_id_to_key[object_id] = key
113
+ else
114
+ object_id_to_key.delete(object_id)
115
+ end
116
+ end
112
117
  end
113
- end
118
+ else
119
+ garbage_cleaner.track(object)
114
120
 
115
- object
121
+ objects[object_id] = WeakRef.new(object)
122
+
123
+ if @key_method
124
+ key = object.send(@key_method)
125
+
126
+ if key
127
+ key_to_object_id[key] = object_id
128
+ object_id_to_key[object_id] = key
129
+ end
130
+ end
131
+
132
+ object
133
+ end
116
134
  end
117
135
 
118
136
  def include?(object_or_object_id)
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.110
4
+ version: 0.0.112
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi