foobara 0.5.10 → 0.6.0
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.
Potentially problematic release.
This version of foobara might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +13 -0
- data/lib/foobara/all.rb +4 -2
- data/projects/command/src/command_pattern_implementation/concerns/command_data.rb +3 -3
- data/projects/command/src/command_pattern_implementation/concerns/domain_mappers.rb +2 -2
- data/projects/command/src/command_pattern_implementation/concerns/errors.rb +27 -27
- data/projects/command/src/command_pattern_implementation/concerns/errors_type.rb +7 -11
- data/projects/command/src/command_pattern_implementation/concerns/inputs.rb +4 -24
- data/projects/command/src/command_pattern_implementation/concerns/inputs_type.rb +9 -14
- data/projects/command/src/command_pattern_implementation/concerns/reflection.rb +7 -20
- data/projects/command/src/command_pattern_implementation/concerns/runtime.rb +3 -48
- data/projects/command/src/command_pattern_implementation/concerns/subcommands.rb +5 -5
- data/projects/command/src/command_pattern_implementation.rb +0 -1
- data/projects/command_connectors/lib/foobara/command_connectors.rb +1 -1
- data/projects/command_connectors/spec/command_connector_spec.rb +63 -4
- data/projects/command_connectors/spec/spec_helper.rb +1 -1
- data/projects/command_connectors/src/command_connector/concerns/desugarizers.rb +5 -5
- data/projects/command_connectors/src/command_connector/concerns/reflection.rb +4 -4
- data/projects/command_connectors/src/command_connector/request.rb +26 -10
- data/projects/command_connectors/src/command_connector/response.rb +2 -0
- data/projects/command_connectors/src/command_connector.rb +62 -58
- data/projects/command_connectors/src/command_registry/exposed_command.rb +7 -2
- data/projects/command_connectors/src/command_registry.rb +15 -15
- data/projects/command_connectors/src/desugarizer.rb +2 -2
- data/projects/command_connectors/src/desugarizers/attributes.rb +8 -8
- data/projects/command_connectors/src/desugarizers/auth.rb +1 -1
- data/projects/command_connectors/src/desugarizers/set_inputs.rb +3 -3
- data/projects/command_connectors/src/desugarizers/symbols_to_true.rb +2 -2
- data/projects/command_connectors/src/request_mutator.rb +6 -6
- data/projects/command_connectors/src/response_mutator.rb +6 -6
- data/projects/command_connectors/src/transformed_command.rb +39 -36
- data/projects/command_connectors/src/transformers/auth_errors_transformer.rb +2 -2
- data/projects/command_connectors/src/transformers/entity_to_primary_key_inputs_transformer.rb +2 -2
- data/projects/command_connectors/src/transformers/load_delegated_attributes_entities_pre_commit_transformer.rb +1 -1
- data/projects/domain_mapper/src/domain_mapper.rb +4 -4
- data/projects/domain_mapper/src/domain_mapper_lookups.rb +3 -3
- data/projects/entities/projects/detached_entity/lib/foobara/detached_entity.rb +1 -1
- data/projects/entities/projects/detached_entity/src/concerns/associations.rb +18 -18
- data/projects/entities/projects/detached_entity/src/concerns/initialization.rb +2 -2
- data/projects/entities/projects/detached_entity/src/concerns/primary_key.rb +4 -4
- data/projects/entities/projects/detached_entity/src/concerns/types.rb +2 -2
- data/projects/entities/projects/detached_entity/src/detached_entity_type.rb +4 -4
- data/projects/entities/projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/primary_key.rb +1 -1
- data/projects/entities/projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/model_instance_is_valid.rb +2 -2
- data/projects/entities/projects/detached_entity/src/extensions/type_declarations/handlers/registered_type_declaration/validate_primary_key_present.rb +30 -0
- data/projects/entities/projects/detached_entity/src/remove_sensitive_values_transformer_extensions.rb +2 -2
- data/projects/entities/projects/entity/lib/foobara/entity.rb +1 -1
- data/projects/entities/projects/entity/src/concerns/attributes.rb +6 -6
- data/projects/entities/projects/entity/src/concerns/callbacks.rb +1 -1
- data/projects/entities/projects/entity/src/concerns/initialization.rb +8 -8
- data/projects/entities/projects/entity/src/concerns/mutations.rb +4 -4
- data/projects/entities/projects/entity/src/concerns/persistence.rb +3 -3
- data/projects/entities/projects/entity/src/concerns/queries.rb +7 -7
- data/projects/entities/projects/entity/src/extensions/domain/domain_module_extension.rb +4 -4
- data/projects/entities/projects/entity/src/new_prepend.rb +2 -2
- data/projects/entities/projects/entity/src/not_found_error.rb +8 -8
- data/projects/entities/projects/entity/src/sensitive_value_removers/entity.rb +8 -5
- data/projects/entities/projects/in_memory_crud_driver_minimal/src/in_memory_minimal.rb +4 -4
- data/projects/entities/projects/model_attribute_helpers/lib/foobara/model_attribute_helpers.rb +0 -2
- data/projects/entities/projects/model_attribute_helpers/src/attribute_helper_aliases.rb +1 -1
- data/projects/entities/projects/model_attribute_helpers/src/attribute_helpers.rb +2 -2
- data/projects/entities/projects/nested_transactionable/lib/foobara/nested_transactionable.rb +5 -5
- data/projects/entities/projects/persistence/lib/foobara/persistence.rb +1 -1
- data/projects/entities/projects/persistence/src/entity_attributes_crud_driver.rb +35 -37
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/entity_callback_handling.rb +25 -25
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/state_transitions.rb +8 -8
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/transaction_tracking.rb +1 -1
- data/projects/entities/projects/persistence/src/entity_base/transaction.rb +9 -9
- data/projects/entities/projects/persistence/src/entity_base/transaction_table/concerns/record_tracking.rb +4 -4
- data/projects/entities/projects/persistence/src/entity_base/transaction_table.rb +52 -52
- data/projects/entities/projects/persistence/src/entity_base.rb +7 -7
- data/projects/entities/projects/persistence/src/persistence.rb +23 -23
- data/projects/entities/projects/weak_object_set/src/weak_object_set.rb +16 -16
- data/projects/entities/spec/builtin_types/detached_entity_spec.rb +1 -1
- data/projects/entities/spec/builtin_types/entity_spec.rb +1 -1
- data/projects/entities/spec/builtin_types/model_spec.rb +1 -1
- data/projects/entities/spec/entity/extending_existing_spec.rb +1 -1
- data/projects/entities/spec/entity/from_type_declaration_spec.rb +1 -1
- data/projects/entities/spec/model/model_spec.rb +2 -2
- data/projects/entities/spec/spec_helper.rb +1 -1
- data/projects/entities_plumbing/lib/foobara/entities_plumbing.rb +6 -2
- data/projects/entities_plumbing/spec/inputs_spec.rb +54 -0
- data/projects/entities_plumbing/spec/spec_helper.rb +1 -1
- data/projects/entities_plumbing/spec/transaction_spec.rb +2 -2
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entities.rb +21 -5
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_errors_type.rb +23 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_inputs.rb +33 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_reflection.rb +39 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/runtime.rb +39 -0
- data/projects/manifest/spec/spec_helper.rb +1 -1
- data/projects/manifest/src/base_manifest.rb +9 -9
- data/projects/manifest/src/model.rb +4 -4
- data/projects/manifest/src/type.rb +3 -3
- data/projects/manifest/src/type_declaration.rb +4 -4
- data/projects/model_plumbing/lib/foobara/model_plumbing.rb +2 -0
- data/projects/model_plumbing/src/extensions/command_pattern_implementation/concerns/model_inputs_type.rb +35 -0
- data/projects/typesystem/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_asc.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_both.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_desc.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/application.css +1 -0
- data/projects/typesystem/coverage/assets/0.13.2/application.js +7 -0
- data/projects/typesystem/coverage/assets/0.13.2/colorbox/border.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/colorbox/controls.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/colorbox/loading.gif +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/colorbox/loading_background.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/favicon_green.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/favicon_red.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/favicon_yellow.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-icons_222222_256x240.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-icons_2e83ff_256x240.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-icons_454545_256x240.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-icons_888888_256x240.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/loading.gif +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/magnify.png +0 -0
- data/projects/typesystem/coverage/index.html +215756 -0
- data/projects/typesystem/projects/builtin_types/lib/foobara/builtin_types.rb +1 -1
- data/projects/typesystem/projects/builtin_types/src/builtin_types.rb +8 -8
- data/projects/typesystem/projects/builtin_types/src/duck/supported_validators/one_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/module_desugarizer.rb +2 -2
- data/projects/typesystem/projects/builtin_types/src/email/validator_base.rb +4 -4
- data/projects/typesystem/projects/callback/src/block/concerns/block_parameter_required.rb +2 -2
- data/projects/typesystem/projects/callback/src/block/concerns/keyword_argumentable_block.rb +2 -2
- data/projects/typesystem/projects/callback/src/block/concerns/single_argument_block.rb +2 -2
- data/projects/typesystem/projects/callback/src/block.rb +4 -4
- data/projects/typesystem/projects/callback/src/registry/base.rb +10 -10
- data/projects/typesystem/projects/callback/src/registry/conditioned.rb +2 -2
- data/projects/typesystem/projects/callback/src/registry/multiple_action.rb +6 -6
- data/projects/typesystem/projects/callback/src/runner.rb +4 -4
- data/projects/typesystem/projects/callback/src/set.rb +4 -4
- data/projects/typesystem/projects/common/src/data_path.rb +14 -14
- data/projects/typesystem/projects/common/src/error.rb +11 -11
- data/projects/typesystem/projects/common/src/error_collection.rb +14 -14
- data/projects/typesystem/projects/common/src/error_key.rb +5 -3
- data/projects/typesystem/projects/common/src/outcome.rb +5 -5
- data/projects/typesystem/projects/common/src/possible_error.rb +2 -2
- data/projects/typesystem/projects/concerns/src/concern.rb +3 -3
- data/projects/typesystem/projects/delegate/src/extensions/module.rb +4 -4
- data/projects/typesystem/projects/domain/lib/foobara/domain.rb +2 -2
- data/projects/typesystem/projects/domain/src/domain.rb +5 -5
- data/projects/typesystem/projects/domain/src/domain_module_extension.rb +22 -22
- data/projects/typesystem/projects/domain/src/extensions/foobara.rb +6 -6
- data/projects/typesystem/projects/domain/src/module_extension.rb +4 -4
- data/projects/typesystem/projects/domain/src/organization.rb +6 -6
- data/projects/typesystem/projects/enumerated/src/accessors.rb +4 -4
- data/projects/typesystem/projects/enumerated/src/values.rb +14 -14
- data/projects/{entities → typesystem}/projects/model/lib/foobara/model.rb +1 -1
- data/projects/{entities → typesystem}/projects/model/src/concerns/classes.rb +4 -4
- data/projects/{entities → typesystem}/projects/model/src/concerns/types.rb +5 -5
- data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/casters/hash.rb +1 -1
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/attributes_handler_desugarizer.rb +2 -2
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/model_class_desugarizer.rb +6 -6
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/to_type_transformer.rb +4 -4
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb +2 -2
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/registered_type_declaration/model_class_desugarizer.rb +6 -10
- data/projects/{entities → typesystem}/projects/model/src/model.rb +13 -13
- data/projects/{entities → typesystem}/projects/model/src/sensitive_value_removers/model.rb +1 -1
- data/projects/typesystem/projects/namespace/src/ambiguous_registry.rb +5 -5
- data/projects/typesystem/projects/namespace/src/base_registry.rb +8 -8
- data/projects/typesystem/projects/namespace/src/is_namespace.rb +19 -19
- data/projects/typesystem/projects/namespace/src/namespace/lookup_mode.rb +2 -2
- data/projects/typesystem/projects/namespace/src/namespace.rb +5 -5
- data/projects/typesystem/projects/namespace/src/namespace_helpers.rb +4 -4
- data/projects/typesystem/projects/namespace/src/prefixless_registry.rb +3 -3
- data/projects/typesystem/projects/namespace/src/scoped.rb +7 -7
- data/projects/typesystem/projects/project/src/foobara.rb +13 -7
- data/projects/typesystem/projects/project/src/project.rb +1 -1
- data/projects/typesystem/projects/state_machine/src/callbacks.rb +14 -14
- data/projects/typesystem/projects/state_machine/src/state_machine.rb +2 -2
- data/projects/typesystem/projects/state_machine/src/sugar.rb +3 -3
- data/projects/typesystem/projects/type_declarations/lib/foobara/type_declarations.rb +1 -1
- data/projects/typesystem/projects/type_declarations/src/attributes.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/from_yaml.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/reject.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/set.rb +4 -4
- data/projects/typesystem/projects/type_declarations/src/desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/dsl/attributes.rb +9 -9
- data/projects/typesystem/projects/type_declarations/src/error_extension.rb +6 -6
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/array_desugarizer.rb +3 -3
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_attributes_type_declaration/element_type_declarations_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_registered_type_declaration.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/registered_type_declaration.rb +4 -3
- data/projects/typesystem/projects/type_declarations/src/remove_sensitive_values_transformer.rb +3 -3
- data/projects/typesystem/projects/type_declarations/src/type_builder.rb +5 -5
- data/projects/typesystem/projects/type_declarations/src/type_declaration.rb +7 -1
- data/projects/typesystem/projects/type_declarations/src/type_declaration_handler.rb +13 -13
- data/projects/typesystem/projects/type_declarations/src/type_declaration_handler_registry.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/type_declaration_validator.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/type_declarations.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/with_registries.rb +2 -2
- data/projects/typesystem/projects/types/src/extensions/error.rb +5 -5
- data/projects/typesystem/projects/types/src/type/concerns/reflection.rb +22 -22
- data/projects/typesystem/projects/types/src/type/concerns/supported_processor_registration.rb +4 -4
- data/projects/typesystem/projects/types/src/type.rb +25 -25
- data/projects/typesystem/projects/value/src/caster.rb +11 -11
- data/projects/typesystem/projects/value/src/data_error.rb +1 -1
- data/projects/typesystem/projects/value/src/mutator.rb +3 -3
- data/projects/typesystem/projects/value/src/processor/casting.rb +6 -6
- data/projects/typesystem/projects/value/src/processor/pipeline.rb +2 -2
- data/projects/typesystem/projects/value/src/processor/runner.rb +1 -1
- data/projects/typesystem/projects/value/src/processor/selection.rb +3 -3
- data/projects/typesystem/projects/value/src/processor.rb +23 -23
- data/projects/typesystem/projects/value/src/transformer.rb +5 -5
- data/projects/typesystem/projects/value/src/validator.rb +3 -3
- data/projects/typesystem/spec/builtin_types/custom_type_spec.rb +2 -2
- data/projects/typesystem/spec/builtin_types/instance_of_spec.rb +1 -1
- data/projects/typesystem/spec/foobara/foobara_spec.rb +18 -8
- data/projects/typesystem/spec/namespace/foobara_simulation_spec.rb +1 -1
- data/projects/typesystem/spec/spec_helper.rb +1 -1
- data/projects/typesystem/spec/state_machine/callbacks_spec.rb +1 -1
- data/projects/typesystem/spec/value/caster_spec.rb +1 -1
- data/version.rb +2 -2
- metadata +75 -35
- /data/projects/{command/src → entities_plumbing/src/extensions}/command_pattern_implementation/concerns/transactions.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/concerns/aliases.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/concerns/reflection.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/supported_transformers/mutable.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/validators/model_instance_is_valid.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/array_with_symbolic_elements.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_validator.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/hash_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/move_private_from_element_types_to_root.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/symbolize_private.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/valid_attribute_names.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/model_class_type_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/mutable_validator.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/to_type_transformer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/lazy_element_types/model.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/sensitive_type_removers/extended_model.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/sensitive_type_removers/model.rb +0 -0
|
@@ -10,7 +10,7 @@ module Foobara
|
|
|
10
10
|
module EntityCallbackHandling
|
|
11
11
|
class << self
|
|
12
12
|
def reset_all
|
|
13
|
-
Foobara.raise_if_production!
|
|
13
|
+
Foobara.raise_if_production!
|
|
14
14
|
install!
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -25,10 +25,10 @@ module Foobara
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
unless transaction.open?
|
|
28
|
-
# :
|
|
28
|
+
# simplecov:disable
|
|
29
29
|
raise CurrentTransactionIsClosedError,
|
|
30
30
|
"Cannot modify #{record} because current transaction is not open"
|
|
31
|
-
# :
|
|
31
|
+
# simplecov:enable
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
transaction.updated(record)
|
|
@@ -38,17 +38,17 @@ module Foobara
|
|
|
38
38
|
transaction = Transaction.open_transaction_for(record)
|
|
39
39
|
|
|
40
40
|
unless transaction
|
|
41
|
-
# :
|
|
41
|
+
# simplecov:disable
|
|
42
42
|
raise NoCurrentTransactionError,
|
|
43
43
|
"Cannot modify #{record} because there's no current transaction"
|
|
44
|
-
# :
|
|
44
|
+
# simplecov:enable
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
unless transaction.open?
|
|
48
|
-
# :
|
|
48
|
+
# simplecov:disable
|
|
49
49
|
raise CurrentTransactionIsClosedError,
|
|
50
50
|
"Cannot modify #{record} because current transaction is not open"
|
|
51
|
-
# :
|
|
51
|
+
# simplecov:enable
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
transaction.updated(record)
|
|
@@ -58,17 +58,17 @@ module Foobara
|
|
|
58
58
|
transaction = Transaction.open_transaction_for(record)
|
|
59
59
|
|
|
60
60
|
unless transaction
|
|
61
|
-
# :
|
|
61
|
+
# simplecov:disable
|
|
62
62
|
raise NoCurrentTransactionError,
|
|
63
63
|
"Cannot modify #{record} because there's no current transaction"
|
|
64
|
-
# :
|
|
64
|
+
# simplecov:enable
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
unless transaction.open?
|
|
68
|
-
# :
|
|
68
|
+
# simplecov:disable
|
|
69
69
|
raise CurrentTransactionIsClosedError,
|
|
70
70
|
"Cannot modify #{record} because current transaction is not open"
|
|
71
|
-
# :
|
|
71
|
+
# simplecov:enable
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
transaction.hard_deleted(record)
|
|
@@ -78,17 +78,17 @@ module Foobara
|
|
|
78
78
|
transaction = Transaction.open_transaction_for(record)
|
|
79
79
|
|
|
80
80
|
unless transaction
|
|
81
|
-
# :
|
|
81
|
+
# simplecov:disable
|
|
82
82
|
raise NoCurrentTransactionError,
|
|
83
83
|
"Cannot modify #{record} because there's no current transaction"
|
|
84
|
-
# :
|
|
84
|
+
# simplecov:enable
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
unless transaction.open?
|
|
88
|
-
# :
|
|
88
|
+
# simplecov:disable
|
|
89
89
|
raise CurrentTransactionIsClosedError,
|
|
90
90
|
"Cannot modify #{record} because current transaction is not open"
|
|
91
|
-
# :
|
|
91
|
+
# simplecov:enable
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
transaction.unhard_deleted(record)
|
|
@@ -97,17 +97,17 @@ module Foobara
|
|
|
97
97
|
Entity.after_initialized_loaded do |record:, **|
|
|
98
98
|
transaction = Persistence.current_transaction(record)
|
|
99
99
|
unless transaction
|
|
100
|
-
# :
|
|
100
|
+
# simplecov:disable
|
|
101
101
|
raise NoCurrentTransactionError,
|
|
102
102
|
"Cannot initialize #{record} because there's no current transaction"
|
|
103
|
-
# :
|
|
103
|
+
# simplecov:enable
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
unless transaction.open?
|
|
107
|
-
# :
|
|
107
|
+
# simplecov:disable
|
|
108
108
|
raise CurrentTransactionIsClosedError,
|
|
109
109
|
"Cannot initialize #{record} because current transaction is not open"
|
|
110
|
-
# :
|
|
110
|
+
# simplecov:enable
|
|
111
111
|
end
|
|
112
112
|
# TODO: we need a way to not blow up here in case of non-block form of transaction
|
|
113
113
|
transaction.track_loaded(record)
|
|
@@ -122,10 +122,10 @@ module Foobara
|
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
unless transaction.open?
|
|
125
|
-
# :
|
|
125
|
+
# simplecov:disable
|
|
126
126
|
raise CurrentTransactionIsClosedError,
|
|
127
127
|
"Cannot initialize #{record} because current transaction is not open"
|
|
128
|
-
# :
|
|
128
|
+
# simplecov:enable
|
|
129
129
|
end
|
|
130
130
|
# TODO: we need a way to not blow up here in case of non-block form of transaction
|
|
131
131
|
transaction.track_created(record)
|
|
@@ -135,17 +135,17 @@ module Foobara
|
|
|
135
135
|
transaction = Persistence.current_transaction(record)
|
|
136
136
|
|
|
137
137
|
unless transaction
|
|
138
|
-
# :
|
|
138
|
+
# simplecov:disable
|
|
139
139
|
raise NoCurrentTransactionError,
|
|
140
140
|
"Cannot initialize #{record} because there's no current transaction"
|
|
141
|
-
# :
|
|
141
|
+
# simplecov:enable
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
unless transaction.open?
|
|
145
|
-
# :
|
|
145
|
+
# simplecov:disable
|
|
146
146
|
raise CurrentTransactionIsClosedError,
|
|
147
147
|
"Cannot initialize #{record} because current transaction is not open"
|
|
148
|
-
# :
|
|
148
|
+
# simplecov:enable
|
|
149
149
|
end
|
|
150
150
|
# TODO: we need a way to not blow up here in case of non-block form of transaction
|
|
151
151
|
transaction.track_unloaded_thunk(record)
|
|
@@ -32,10 +32,10 @@ module Foobara
|
|
|
32
32
|
end
|
|
33
33
|
entity_attributes_crud_driver.flush_transaction(raw_tx)
|
|
34
34
|
rescue => e
|
|
35
|
-
# :
|
|
35
|
+
# simplecov:disable
|
|
36
36
|
rollback!(e)
|
|
37
37
|
raise
|
|
38
|
-
# :
|
|
38
|
+
# simplecov:enable
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# Should communicate somehow that this is only in-memory.
|
|
@@ -46,10 +46,10 @@ module Foobara
|
|
|
46
46
|
end
|
|
47
47
|
entity_attributes_crud_driver.revert_transaction(raw_tx)
|
|
48
48
|
rescue => e
|
|
49
|
-
# :
|
|
49
|
+
# simplecov:disable
|
|
50
50
|
rollback!(e)
|
|
51
51
|
raise
|
|
52
|
-
# :
|
|
52
|
+
# simplecov:enable
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def commit!
|
|
@@ -62,10 +62,10 @@ module Foobara
|
|
|
62
62
|
each_table(&:transaction_closed)
|
|
63
63
|
end
|
|
64
64
|
rescue => e
|
|
65
|
-
# :
|
|
65
|
+
# simplecov:disable
|
|
66
66
|
rollback!(e)
|
|
67
67
|
raise
|
|
68
|
-
# :
|
|
68
|
+
# simplecov:enable
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
def commit_nested!
|
|
@@ -75,10 +75,10 @@ module Foobara
|
|
|
75
75
|
each_table(&:transaction_closed)
|
|
76
76
|
end
|
|
77
77
|
rescue => e
|
|
78
|
-
# :
|
|
78
|
+
# simplecov:disable
|
|
79
79
|
rollback!(e)
|
|
80
80
|
raise
|
|
81
|
-
# :
|
|
81
|
+
# simplecov:enable
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
# TODO: this belongs elsewhere
|
|
@@ -58,9 +58,9 @@ module Foobara
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
unless entity_base == entity_class.entity_base
|
|
61
|
-
# :
|
|
61
|
+
# simplecov:disable
|
|
62
62
|
raise "#{entity_class} is from a different entity base! Cannot proceed."
|
|
63
|
-
# :
|
|
63
|
+
# simplecov:enable
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
table = tables[entity_class]
|
|
@@ -70,9 +70,9 @@ module Foobara
|
|
|
70
70
|
else
|
|
71
71
|
if defined?(@ordered_tables)
|
|
72
72
|
# TODO: test this path
|
|
73
|
-
# :
|
|
73
|
+
# simplecov:disable
|
|
74
74
|
remove_instance_variable(:@ordered_tables)
|
|
75
|
-
# :
|
|
75
|
+
# simplecov:enable
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
tables[entity_class] = TransactionTable.new(self, entity_class)
|
|
@@ -102,17 +102,17 @@ module Foobara
|
|
|
102
102
|
def load(record_or_entity_class, record_id = nil)
|
|
103
103
|
entity_or_id = if record_or_entity_class.is_a?(Entity)
|
|
104
104
|
if record_id
|
|
105
|
-
# :
|
|
105
|
+
# simplecov:disable
|
|
106
106
|
raise ArgumentError, "Do not give a record_id when also giving a record"
|
|
107
|
-
# :
|
|
107
|
+
# simplecov:enable
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
record_or_entity_class
|
|
111
111
|
else
|
|
112
112
|
unless record_id
|
|
113
|
-
# :
|
|
113
|
+
# simplecov:disable
|
|
114
114
|
raise ArgumentError, "Must give a record_id when passing in an entity class"
|
|
115
|
-
# :
|
|
115
|
+
# simplecov:enable
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
record_id
|
|
@@ -148,7 +148,7 @@ module Foobara
|
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
def load_aggregate(record)
|
|
151
|
-
load_aggregates([record])
|
|
151
|
+
load_aggregates([record])[0]
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
def track_unloaded_thunk(entity)
|
|
@@ -16,9 +16,9 @@ module Foobara
|
|
|
16
16
|
|
|
17
17
|
def loading(record)
|
|
18
18
|
if loading?(record)
|
|
19
|
-
# :
|
|
19
|
+
# simplecov:disable
|
|
20
20
|
raise "Already loading #{record}"
|
|
21
|
-
# :
|
|
21
|
+
# simplecov:enable
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
begin
|
|
@@ -69,9 +69,9 @@ module Foobara
|
|
|
69
69
|
|
|
70
70
|
# TODO: is this check redundant? Maybe have the entity explode directly instead?
|
|
71
71
|
if hard_deleted?(record)
|
|
72
|
-
# :
|
|
72
|
+
# simplecov:disable
|
|
73
73
|
raise "Cannot update a hard deleted record"
|
|
74
|
-
# :
|
|
74
|
+
# simplecov:enable
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
unless created?(record)
|
|
@@ -32,21 +32,21 @@ module Foobara
|
|
|
32
32
|
|
|
33
33
|
def find_tracked(record_id)
|
|
34
34
|
unless record_id
|
|
35
|
-
# :
|
|
35
|
+
# simplecov:disable
|
|
36
36
|
raise ArgumentError, "Cannot use a blank primary key value"
|
|
37
|
-
# :
|
|
37
|
+
# simplecov:enable
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
if record_id.is_a?(::String) && record_id.empty?
|
|
41
|
-
# :
|
|
41
|
+
# simplecov:disable
|
|
42
42
|
raise ArgumentError, "Cannot use a blank primary key value"
|
|
43
|
-
# :
|
|
43
|
+
# simplecov:enable
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
if record_id.is_a?(::Symbol) && record_id.to_s.empty?
|
|
47
|
-
# :
|
|
47
|
+
# simplecov:disable
|
|
48
48
|
raise ArgumentError, "Cannot use a blank primary key value"
|
|
49
|
-
# :
|
|
49
|
+
# simplecov:enable
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
tracked_records.find_by_key(record_id)
|
|
@@ -66,33 +66,33 @@ module Foobara
|
|
|
66
66
|
|
|
67
67
|
def load(entity_or_record_id)
|
|
68
68
|
if entity_or_record_id.nil?
|
|
69
|
-
# :
|
|
69
|
+
# simplecov:disable
|
|
70
70
|
raise "Expected a record or record primary key but received nil"
|
|
71
|
-
# :
|
|
71
|
+
# simplecov:enable
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
if entity_or_record_id.is_a?(Entity)
|
|
75
75
|
entity = if entity_or_record_id.persisted?
|
|
76
76
|
unless entity_or_record_id.primary_key
|
|
77
|
-
# :
|
|
77
|
+
# simplecov:disable
|
|
78
78
|
raise "Did not expect a record to be persisted but have no primary key"
|
|
79
|
-
# :
|
|
79
|
+
# simplecov:enable
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
tracked_records.find_by_key(entity_or_record_id.primary_key)
|
|
83
83
|
else
|
|
84
|
-
# :
|
|
84
|
+
# simplecov:disable
|
|
85
85
|
raise "Cannot load an unpersisted record!"
|
|
86
|
-
# :
|
|
86
|
+
# simplecov:enable
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# rubocop:disable Lint/IdentityComparison
|
|
90
90
|
if entity &&
|
|
91
91
|
(!entity.equal?(entity_or_record_id) || entity.object_id != entity_or_record_id.object_id)
|
|
92
|
-
# :
|
|
92
|
+
# simplecov:disable
|
|
93
93
|
raise "This transaction is already tracking a different entity with the same primary key." \
|
|
94
94
|
"Try passing in the primary key instead of constructing an unloaded entity to pass in."
|
|
95
|
-
# :
|
|
95
|
+
# simplecov:enable
|
|
96
96
|
end
|
|
97
97
|
# rubocop:enable Lint/IdentityComparison
|
|
98
98
|
|
|
@@ -101,27 +101,27 @@ module Foobara
|
|
|
101
101
|
record_id = entity_or_record_id
|
|
102
102
|
|
|
103
103
|
if record_id.is_a?(::Hash)
|
|
104
|
-
# :
|
|
104
|
+
# simplecov:disable
|
|
105
105
|
raise ArgumentError, "Unlikely that you meant to use a hash as a primary key"
|
|
106
|
-
# :
|
|
106
|
+
# simplecov:enable
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
unless record_id
|
|
110
|
-
# :
|
|
110
|
+
# simplecov:disable
|
|
111
111
|
raise ArgumentError, "Cannot use a blank primary key value"
|
|
112
|
-
# :
|
|
112
|
+
# simplecov:enable
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
if record_id.is_a?(::String) && record_id.empty?
|
|
116
|
-
# :
|
|
116
|
+
# simplecov:disable
|
|
117
117
|
raise ArgumentError, "Cannot use a blank primary key value"
|
|
118
|
-
# :
|
|
118
|
+
# simplecov:enable
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
if record_id.is_a?(::Symbol) && record_id.to_s.empty?
|
|
122
|
-
# :
|
|
122
|
+
# simplecov:disable
|
|
123
123
|
raise ArgumentError, "Cannot use a blank primary key value"
|
|
124
|
-
# :
|
|
124
|
+
# simplecov:enable
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
entity = tracked_records.find_by_key(record_id)
|
|
@@ -136,9 +136,9 @@ module Foobara
|
|
|
136
136
|
attributes = normalize_attributes(entity_attributes_crud_driver_table.find!(record_id))
|
|
137
137
|
|
|
138
138
|
unless attributes
|
|
139
|
-
# :
|
|
139
|
+
# simplecov:disable
|
|
140
140
|
raise NoRecordFound, "could not find record for #{entity_class.full_entity_name}:#{record_id}"
|
|
141
|
-
# :
|
|
141
|
+
# simplecov:enable
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
entity.successfully_loaded(attributes)
|
|
@@ -147,9 +147,9 @@ module Foobara
|
|
|
147
147
|
attributes = normalize_attributes(entity_attributes_crud_driver_table.find!(record_id))
|
|
148
148
|
|
|
149
149
|
unless attributes
|
|
150
|
-
# :
|
|
150
|
+
# simplecov:disable
|
|
151
151
|
raise NoRecordFound, "could not find record for #{entity_class.full_entity_name}:#{record_id}"
|
|
152
|
-
# :
|
|
152
|
+
# simplecov:enable
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
transaction.loaded(entity_class, attributes)
|
|
@@ -168,23 +168,23 @@ module Foobara
|
|
|
168
168
|
|
|
169
169
|
entity = if entity_or_record_id.persisted?
|
|
170
170
|
unless entity_or_record_id.primary_key
|
|
171
|
-
# :
|
|
171
|
+
# simplecov:disable
|
|
172
172
|
raise "Did not expect a record to be persisted but have no primary key"
|
|
173
|
-
# :
|
|
173
|
+
# simplecov:enable
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
tracked_records.find_by_key(entity_or_record_id.primary_key)
|
|
177
177
|
else
|
|
178
|
-
# :
|
|
178
|
+
# simplecov:disable
|
|
179
179
|
raise "Cannot load an unpersisted record!"
|
|
180
|
-
# :
|
|
180
|
+
# simplecov:enable
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
if entity && !entity.equal?(entity_or_record_id)
|
|
184
|
-
# :
|
|
184
|
+
# simplecov:disable
|
|
185
185
|
raise "This transaction is already tracking a different entity with the same primary key." \
|
|
186
186
|
"Try passing in the primary key instead of constructing an unloaded entity to pass in."
|
|
187
|
-
# :
|
|
187
|
+
# simplecov:enable
|
|
188
188
|
end
|
|
189
189
|
|
|
190
190
|
record_id = entity.primary_key
|
|
@@ -194,28 +194,28 @@ module Foobara
|
|
|
194
194
|
record_id = entity_or_record_id
|
|
195
195
|
|
|
196
196
|
if record_id.is_a?(::Hash)
|
|
197
|
-
# :
|
|
197
|
+
# simplecov:disable
|
|
198
198
|
raise ArgumentError, "Unlikely that you meant to use a hash as a primary key"
|
|
199
|
-
# :
|
|
199
|
+
# simplecov:enable
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
# TODO: encapsulate this record_id verification
|
|
203
203
|
unless record_id
|
|
204
|
-
# :
|
|
204
|
+
# simplecov:disable
|
|
205
205
|
raise ArgumentError, "Cannot use a blank primary key value"
|
|
206
|
-
# :
|
|
206
|
+
# simplecov:enable
|
|
207
207
|
end
|
|
208
208
|
|
|
209
209
|
if record_id.is_a?(::String) && record_id.empty?
|
|
210
|
-
# :
|
|
210
|
+
# simplecov:disable
|
|
211
211
|
raise ArgumentError, "Cannot use a blank primary key value"
|
|
212
|
-
# :
|
|
212
|
+
# simplecov:enable
|
|
213
213
|
end
|
|
214
214
|
|
|
215
215
|
if record_id.is_a?(::Symbol) && record_id.to_s.empty?
|
|
216
|
-
# :
|
|
216
|
+
# simplecov:disable
|
|
217
217
|
raise ArgumentError, "Cannot use a blank primary key value"
|
|
218
|
-
# :
|
|
218
|
+
# simplecov:enable
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
entity = tracked_records.find_by_key(record_id)
|
|
@@ -323,9 +323,9 @@ module Foobara
|
|
|
323
323
|
# was already considered among tracked records if loaded? is true so do not return it as
|
|
324
324
|
# it has changed and no longer matches
|
|
325
325
|
# TODO: figure out how to test this code path
|
|
326
|
-
# :
|
|
326
|
+
# simplecov:disable
|
|
327
327
|
record = nil
|
|
328
|
-
# :
|
|
328
|
+
# simplecov:enable
|
|
329
329
|
else
|
|
330
330
|
loading(record) do
|
|
331
331
|
record.successfully_loaded(found_attributes)
|
|
@@ -356,9 +356,9 @@ module Foobara
|
|
|
356
356
|
when ::Array, Value::DataPath
|
|
357
357
|
path_filters[attribute_name_or_path] = value
|
|
358
358
|
else
|
|
359
|
-
# :
|
|
359
|
+
# simplecov:disable
|
|
360
360
|
raise "Unexpected filter type: #{attribute_name_or_path.class}"
|
|
361
|
-
# :
|
|
361
|
+
# simplecov:enable
|
|
362
362
|
end
|
|
363
363
|
end
|
|
364
364
|
|
|
@@ -397,9 +397,9 @@ module Foobara
|
|
|
397
397
|
# was already considered among tracked records if loaded? is true so do not return it as
|
|
398
398
|
# it has changed and no longer matches
|
|
399
399
|
# TODO: figure out how to test this code path
|
|
400
|
-
# :
|
|
400
|
+
# simplecov:disable
|
|
401
401
|
record = nil
|
|
402
|
-
# :
|
|
402
|
+
# simplecov:enable
|
|
403
403
|
else
|
|
404
404
|
loading(record) do
|
|
405
405
|
record.successfully_loaded(found_attributes)
|
|
@@ -462,7 +462,7 @@ module Foobara
|
|
|
462
462
|
|
|
463
463
|
if record
|
|
464
464
|
# TODO: test this code path
|
|
465
|
-
# :
|
|
465
|
+
# simplecov:disable
|
|
466
466
|
if record.loaded?
|
|
467
467
|
# was already considered among tracked records if loaded? is true so do not return it as
|
|
468
468
|
# it has changed and no longer matches
|
|
@@ -472,7 +472,7 @@ module Foobara
|
|
|
472
472
|
record.successfully_loaded(found_attributes)
|
|
473
473
|
end
|
|
474
474
|
end
|
|
475
|
-
# :
|
|
475
|
+
# simplecov:enable
|
|
476
476
|
else
|
|
477
477
|
record = entity_class.loaded(found_attributes)
|
|
478
478
|
end
|
|
@@ -526,7 +526,7 @@ module Foobara
|
|
|
526
526
|
|
|
527
527
|
if record
|
|
528
528
|
# TODO: test this code path
|
|
529
|
-
# :
|
|
529
|
+
# simplecov:disable
|
|
530
530
|
if record.loaded?
|
|
531
531
|
# was already considered among tracked records if loaded? is true so do not return it as
|
|
532
532
|
# it has changed and no longer matches
|
|
@@ -536,7 +536,7 @@ module Foobara
|
|
|
536
536
|
record.successfully_loaded(found_attributes)
|
|
537
537
|
end
|
|
538
538
|
end
|
|
539
|
-
# :
|
|
539
|
+
# simplecov:enable
|
|
540
540
|
else
|
|
541
541
|
record = entity_class.loaded(found_attributes)
|
|
542
542
|
end
|
|
@@ -554,9 +554,9 @@ module Foobara
|
|
|
554
554
|
|
|
555
555
|
def track_created(entity)
|
|
556
556
|
if entity.persisted?
|
|
557
|
-
# :
|
|
557
|
+
# simplecov:disable
|
|
558
558
|
raise "Cannot insert #{entity} because it's already persisted."
|
|
559
|
-
# :
|
|
559
|
+
# simplecov:enable
|
|
560
560
|
end
|
|
561
561
|
|
|
562
562
|
created(entity)
|
|
@@ -10,7 +10,7 @@ module Foobara
|
|
|
10
10
|
if existing_transactions.empty?
|
|
11
11
|
block.call
|
|
12
12
|
elsif existing_transactions.size == 1
|
|
13
|
-
existing_transaction = existing_transactions
|
|
13
|
+
existing_transaction = existing_transactions[0]
|
|
14
14
|
|
|
15
15
|
existing_transaction.entity_base.using_transaction(existing_transaction, &block)
|
|
16
16
|
else
|
|
@@ -127,9 +127,9 @@ module Foobara
|
|
|
127
127
|
|
|
128
128
|
def transaction(mode = nil, existing_transaction: nil)
|
|
129
129
|
unless VALID_MODES.include?(mode)
|
|
130
|
-
# :
|
|
130
|
+
# simplecov:disable
|
|
131
131
|
raise ArgumentError, "Mode was #{mode} but expected one of #{VALID_MODES}"
|
|
132
|
-
# :
|
|
132
|
+
# simplecov:enable
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
old_transaction = current_transaction
|
|
@@ -151,16 +151,16 @@ module Foobara
|
|
|
151
151
|
open_nested = true
|
|
152
152
|
elsif mode == :open_new
|
|
153
153
|
if existing_transaction
|
|
154
|
-
# :
|
|
154
|
+
# simplecov:disable
|
|
155
155
|
raise ArgumentError, "Cannot use mode :open_new with existing_transaction:"
|
|
156
|
-
# :
|
|
156
|
+
# simplecov:enable
|
|
157
157
|
end
|
|
158
158
|
else
|
|
159
|
-
# :
|
|
159
|
+
# simplecov:disable
|
|
160
160
|
raise "Transaction already open. " \
|
|
161
161
|
"Use mode :use_existing if you want to make use of the existing transaction. " \
|
|
162
162
|
"Use mode :open_nested if you are actually trying to nest transactions."
|
|
163
|
-
# :
|
|
163
|
+
# simplecov:enable
|
|
164
164
|
end
|
|
165
165
|
end
|
|
166
166
|
|