foobara 0.0.132 → 0.0.133
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/projects/command_connectors/src/transformed_command.rb +4 -0
- data/projects/detached_entity/src/concerns/associations.rb +3 -1
- data/projects/entity/src/concerns/initialization.rb +1 -1
- data/projects/persistence/src/entity_attributes_crud_driver.rb +16 -1
- data/projects/persistence/src/entity_base/transaction_table.rb +107 -11
- data/projects/state_machine/src/state_machine.rb +2 -0
- data/projects/state_machine/src/transitions.rb +22 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 267e71a64eccb434c34233c30b65e56d1c69109667c4ba806645324cf53d9581
|
4
|
+
data.tar.gz: b870b83c02edd0bb5e117a57f769c1adf6c73abbfae68660688d82cdc91b3b1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1226974494886a43bdcf51e00ec0061453d6307e5e031836824747f4b583775edf5b1529fad4280a1520c173e1d3a94253a5bf2885b996d5e7814d426eaac10
|
7
|
+
data.tar.gz: e44c33f5c39c9e32c01c5057ad1a747fa95e07bc47e7e5bdf57b896fdc78bfea18e9f2f09661dc6bfb47da325a452108942c99d7e9d789aae3e4b5c945e57aa3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# [0.0.133] - 2025-06-26
|
2
|
+
|
3
|
+
- Add StateMachine.states_that_can_perform
|
4
|
+
- Add TransformedCommand#raw_inputs
|
5
|
+
- Fix several TransactionTable#find_by* bugs that incorrectly match/don't match in-memory changed records
|
6
|
+
- Fix bug that looked for associations in generic :attributes types
|
7
|
+
|
1
8
|
# [0.0.132] - 2025-06-19
|
2
9
|
|
3
10
|
- Add/improve the description for primary key types in EntityToPrimaryKeyInputsTransformer
|
@@ -253,11 +253,13 @@ module Foobara
|
|
253
253
|
contains_associations?(element_type, false)
|
254
254
|
end
|
255
255
|
elsif type.extends?(BuiltinTypes[:attributes])
|
256
|
-
|
256
|
+
|
257
|
+
type.element_types&.values&.any? do |element_type|
|
257
258
|
if !remove_sensitive || !element_type.sensitive?
|
258
259
|
contains_associations?(element_type, false)
|
259
260
|
end
|
260
261
|
end
|
262
|
+
|
261
263
|
elsif type.extends?(BuiltinTypes[:associative_array])
|
262
264
|
element_types = type.element_types
|
263
265
|
|
@@ -130,8 +130,20 @@ module Foobara
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def find_by_attribute_containing(attribute_name, value)
|
133
|
+
found_type = entity_class.attributes_type.type_at_path("#{attribute_name}.#")
|
134
|
+
|
135
|
+
if value
|
136
|
+
value = restore_attributes(value, found_type)
|
137
|
+
end
|
138
|
+
|
133
139
|
all.find do |found_attributes|
|
134
|
-
found_attributes[attribute_name]
|
140
|
+
found_attributes[attribute_name].any? do |found_value|
|
141
|
+
if found_value
|
142
|
+
found_value = restore_attributes(found_value, found_type)
|
143
|
+
end
|
144
|
+
|
145
|
+
found_value == value
|
146
|
+
end
|
135
147
|
end
|
136
148
|
end
|
137
149
|
|
@@ -291,7 +303,10 @@ module Foobara
|
|
291
303
|
if outcome.success?
|
292
304
|
outcome.result
|
293
305
|
else
|
306
|
+
# TODO: figure out how to test this code path
|
307
|
+
# :nocov:
|
294
308
|
object
|
309
|
+
# :nocov:
|
295
310
|
end
|
296
311
|
end
|
297
312
|
end
|
@@ -260,6 +260,7 @@ module Foobara
|
|
260
260
|
value = entity_class.attributes_type.element_types[attribute_name].element_type.process_value!(value)
|
261
261
|
|
262
262
|
tracked_records.each do |record|
|
263
|
+
next unless record.loaded? || record.created?
|
263
264
|
next if hard_deleted?(record)
|
264
265
|
|
265
266
|
# TODO: what if there are multiple??
|
@@ -274,7 +275,22 @@ module Foobara
|
|
274
275
|
)
|
275
276
|
|
276
277
|
if found_attributes
|
277
|
-
|
278
|
+
found_attributes = normalize_attributes(found_attributes)
|
279
|
+
record_id = primary_key_for_attributes(found_attributes)
|
280
|
+
|
281
|
+
record = find_tracked(record_id)
|
282
|
+
|
283
|
+
if record
|
284
|
+
# was already considered among tracked records if loaded? is true so do not return it as
|
285
|
+
# it has changed and no longer matches
|
286
|
+
unless record.loaded?
|
287
|
+
loading(record) do
|
288
|
+
record.successfully_loaded(found_attributes)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
else
|
292
|
+
entity_class.loaded(found_attributes)
|
293
|
+
end
|
278
294
|
end
|
279
295
|
end
|
280
296
|
|
@@ -286,6 +302,7 @@ module Foobara
|
|
286
302
|
end
|
287
303
|
|
288
304
|
tracked_records.each do |record|
|
305
|
+
next unless record.loaded? || record.created?
|
289
306
|
next if hard_deleted?(record)
|
290
307
|
|
291
308
|
if entity_attributes_crud_driver_table.matches_attributes_filter?(record.attributes, attributes_filter)
|
@@ -293,17 +310,37 @@ module Foobara
|
|
293
310
|
end
|
294
311
|
end
|
295
312
|
|
296
|
-
|
313
|
+
found_attributes_enumerator = entity_attributes_crud_driver_table.find_many_by(attributes_filter)
|
297
314
|
|
298
|
-
|
315
|
+
found_attributes_enumerator.each do |found_attributes|
|
299
316
|
found_attributes = normalize_attributes(found_attributes)
|
300
317
|
record_id = primary_key_for_attributes(found_attributes)
|
301
318
|
|
302
319
|
record = find_tracked(record_id)
|
303
|
-
return record if record
|
304
320
|
|
305
|
-
|
321
|
+
if record
|
322
|
+
if record.loaded?
|
323
|
+
# was already considered among tracked records if loaded? is true so do not return it as
|
324
|
+
# it has changed and no longer matches
|
325
|
+
# TODO: figure out how to test this code path
|
326
|
+
# :nocov:
|
327
|
+
record = nil
|
328
|
+
# :nocov:
|
329
|
+
else
|
330
|
+
loading(record) do
|
331
|
+
record.successfully_loaded(found_attributes)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
else
|
335
|
+
record = entity_class.loaded(found_attributes)
|
336
|
+
end
|
337
|
+
|
338
|
+
if record
|
339
|
+
return record
|
340
|
+
end
|
306
341
|
end
|
342
|
+
|
343
|
+
nil
|
307
344
|
end
|
308
345
|
|
309
346
|
def find_many_by(attributes_filter)
|
@@ -353,9 +390,28 @@ module Foobara
|
|
353
390
|
|
354
391
|
next if yielded_ids.include?(record_id)
|
355
392
|
|
356
|
-
record = find_tracked(record_id)
|
393
|
+
record = find_tracked(record_id)
|
394
|
+
|
395
|
+
if record
|
396
|
+
if record.loaded?
|
397
|
+
# was already considered among tracked records if loaded? is true so do not return it as
|
398
|
+
# it has changed and no longer matches
|
399
|
+
# TODO: figure out how to test this code path
|
400
|
+
# :nocov:
|
401
|
+
record = nil
|
402
|
+
# :nocov:
|
403
|
+
else
|
404
|
+
loading(record) do
|
405
|
+
record.successfully_loaded(found_attributes)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
else
|
409
|
+
record = entity_class.loaded(found_attributes)
|
410
|
+
end
|
357
411
|
|
358
|
-
|
412
|
+
if record
|
413
|
+
yielder << record
|
414
|
+
end
|
359
415
|
end
|
360
416
|
end
|
361
417
|
end
|
@@ -374,6 +430,7 @@ module Foobara
|
|
374
430
|
|
375
431
|
Enumerator.new do |yielder|
|
376
432
|
tracked_records.each do |record|
|
433
|
+
next unless record.loaded? || record.created?
|
377
434
|
next if hard_deleted?(record)
|
378
435
|
|
379
436
|
record_values = record.read_attribute(attribute_name)
|
@@ -401,9 +458,28 @@ module Foobara
|
|
401
458
|
|
402
459
|
next if yielded_ids.include?(record_id)
|
403
460
|
|
404
|
-
record = find_tracked(record_id)
|
461
|
+
record = find_tracked(record_id)
|
462
|
+
|
463
|
+
if record
|
464
|
+
# TODO: test this code path
|
465
|
+
# :nocov:
|
466
|
+
if record.loaded?
|
467
|
+
# was already considered among tracked records if loaded? is true so do not return it as
|
468
|
+
# it has changed and no longer matches
|
469
|
+
record = nil
|
470
|
+
else
|
471
|
+
loading(record) do
|
472
|
+
record.successfully_loaded(found_attributes)
|
473
|
+
end
|
474
|
+
end
|
475
|
+
# :nocov:
|
476
|
+
else
|
477
|
+
record = entity_class.loaded(found_attributes)
|
478
|
+
end
|
405
479
|
|
406
|
-
|
480
|
+
if record
|
481
|
+
yielder << record
|
482
|
+
end
|
407
483
|
end
|
408
484
|
end
|
409
485
|
end
|
@@ -422,6 +498,7 @@ module Foobara
|
|
422
498
|
|
423
499
|
Enumerator.new do |yielder|
|
424
500
|
tracked_records.each do |record|
|
501
|
+
next unless record.loaded? || record.created?
|
425
502
|
next if hard_deleted?(record)
|
426
503
|
|
427
504
|
record_value = record.read_attribute(attribute_name)
|
@@ -445,9 +522,28 @@ module Foobara
|
|
445
522
|
|
446
523
|
next if yielded_ids.include?(record_id)
|
447
524
|
|
448
|
-
record = find_tracked(record_id)
|
525
|
+
record = find_tracked(record_id)
|
526
|
+
|
527
|
+
if record
|
528
|
+
# TODO: test this code path
|
529
|
+
# :nocov:
|
530
|
+
if record.loaded?
|
531
|
+
# was already considered among tracked records if loaded? is true so do not return it as
|
532
|
+
# it has changed and no longer matches
|
533
|
+
record = nil
|
534
|
+
else
|
535
|
+
loading(record) do
|
536
|
+
record.successfully_loaded(found_attributes)
|
537
|
+
end
|
538
|
+
end
|
539
|
+
# :nocov:
|
540
|
+
else
|
541
|
+
record = entity_class.loaded(found_attributes)
|
542
|
+
end
|
449
543
|
|
450
|
-
|
544
|
+
if record
|
545
|
+
yielder << record
|
546
|
+
end
|
451
547
|
end
|
452
548
|
end
|
453
549
|
end
|
@@ -2,6 +2,7 @@ module Foobara
|
|
2
2
|
require_project_file("state_machine", "sugar")
|
3
3
|
require_project_file("state_machine", "callbacks")
|
4
4
|
require_project_file("state_machine", "validations")
|
5
|
+
require_project_file("state_machine", "transitions")
|
5
6
|
|
6
7
|
# TODO: allow quick creation of a statemachine either through better options to #initialize or a
|
7
8
|
# .for method.
|
@@ -10,6 +11,7 @@ module Foobara
|
|
10
11
|
include Callbacks
|
11
12
|
include Validations
|
12
13
|
include TransitionLog
|
14
|
+
include Transitions
|
13
15
|
|
14
16
|
class InvalidTransition < StandardError; end
|
15
17
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Foobara
|
2
|
+
class StateMachine
|
3
|
+
module Transitions
|
4
|
+
include Concern
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def states_that_can_perform(transition)
|
8
|
+
states = []
|
9
|
+
transition = transition.to_sym
|
10
|
+
|
11
|
+
transition_map.each_pair do |from, transitions|
|
12
|
+
if transitions.key?(transition)
|
13
|
+
states << from
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
states
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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.
|
4
|
+
version: 0.0.133
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -406,6 +406,7 @@ files:
|
|
406
406
|
- projects/state_machine/src/state_machine.rb
|
407
407
|
- projects/state_machine/src/sugar.rb
|
408
408
|
- projects/state_machine/src/transition_log.rb
|
409
|
+
- projects/state_machine/src/transitions.rb
|
409
410
|
- projects/state_machine/src/validations.rb
|
410
411
|
- projects/type_declarations/lib/foobara/type_declarations.rb
|
411
412
|
- projects/type_declarations/src/attributes.rb
|