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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Foobara
|
|
2
|
+
module TypeDeclarations
|
|
3
|
+
module Handlers
|
|
4
|
+
class RegisteredTypeDeclaration < TypeDeclarationHandler
|
|
5
|
+
class ValidatePrimaryKeyPresent < TypeDeclarations::TypeDeclarationValidator
|
|
6
|
+
# TODO: seems like maybe we could actually check against types now...
|
|
7
|
+
# like make a type for primary_key: :symbol ??
|
|
8
|
+
class MissingPrimaryKeyError < TypeDeclarationError; end
|
|
9
|
+
|
|
10
|
+
def validation_errors(type_declaration)
|
|
11
|
+
if type_declaration.claimed_but_error?
|
|
12
|
+
klass = type_declaration.declaration_data
|
|
13
|
+
|
|
14
|
+
if klass.is_a?(::Class) && klass < ::Foobara::DetachedEntity
|
|
15
|
+
if klass.model_type.nil? && klass.primary_key_attribute.nil?
|
|
16
|
+
build_error(
|
|
17
|
+
message: "#{klass} doesn't have a primary key attribute set yet. " \
|
|
18
|
+
"Did you forget something like `primary_key :id` in #{klass}?"
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def error_context(_value) ={}
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -26,21 +26,21 @@ module Foobara
|
|
|
26
26
|
|
|
27
27
|
if attribute_name == primary_key_attribute
|
|
28
28
|
if value.nil?
|
|
29
|
-
# :
|
|
29
|
+
# simplecov:disable
|
|
30
30
|
raise "Primary key cannot be set to a blank value"
|
|
31
|
-
# :
|
|
31
|
+
# simplecov:enable
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
if value.is_a?(::String) && value.empty?
|
|
35
|
-
# :
|
|
35
|
+
# simplecov:disable
|
|
36
36
|
raise "Primary key cannot be set to a blank value"
|
|
37
|
-
# :
|
|
37
|
+
# simplecov:enable
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
if value.is_a?(::Symbol) && value.to_s.empty?
|
|
41
|
-
# :
|
|
41
|
+
# simplecov:disable
|
|
42
42
|
raise "Primary key cannot be set to a blank value"
|
|
43
|
-
# :
|
|
43
|
+
# simplecov:enable
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
write_attribute!(attribute_name, value)
|
|
@@ -29,9 +29,9 @@ module Foobara
|
|
|
29
29
|
|
|
30
30
|
# TODO: is this possible?
|
|
31
31
|
if record_id.nil?
|
|
32
|
-
# :
|
|
32
|
+
# simplecov:disable
|
|
33
33
|
raise ArgumentError, "Primary key cannot be blank"
|
|
34
|
-
# :
|
|
34
|
+
# simplecov:enable
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# check if tracked already...
|
|
@@ -58,9 +58,9 @@ module Foobara
|
|
|
58
58
|
record = current_transaction_table.find_tracked(record_id)
|
|
59
59
|
|
|
60
60
|
if record&.loaded?
|
|
61
|
-
# :
|
|
61
|
+
# simplecov:disable
|
|
62
62
|
raise "Already loaded for #{attributes}. Bug maybe?"
|
|
63
|
-
# :
|
|
63
|
+
# simplecov:enable
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
record = __private_new__
|
|
@@ -68,9 +68,9 @@ module Foobara
|
|
|
68
68
|
record.successfully_loaded(attributes)
|
|
69
69
|
|
|
70
70
|
unless record.primary_key
|
|
71
|
-
# :
|
|
71
|
+
# simplecov:disable
|
|
72
72
|
raise "Expected primary key #{primary_key_attribute} to be present!"
|
|
73
|
-
# :
|
|
73
|
+
# simplecov:enable
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
record.fire(:initialized)
|
|
@@ -104,9 +104,9 @@ module Foobara
|
|
|
104
104
|
|
|
105
105
|
def successfully_loaded(attributes)
|
|
106
106
|
if hard_deleted?
|
|
107
|
-
# :
|
|
107
|
+
# simplecov:disable
|
|
108
108
|
raise "Not expecting to load a hard deleted record"
|
|
109
|
-
# :
|
|
109
|
+
# simplecov:enable
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
# TODO: why would we proceed if this is the case? Maybe raise?
|
|
@@ -50,13 +50,13 @@ module Foobara
|
|
|
50
50
|
|
|
51
51
|
object
|
|
52
52
|
elsif type.extends?(BuiltinTypes[:tuple])
|
|
53
|
-
# :
|
|
53
|
+
# simplecov:disable
|
|
54
54
|
raise "Tuple not yet supported"
|
|
55
|
-
# :
|
|
55
|
+
# simplecov:enable
|
|
56
56
|
elsif type.extends?(BuiltinTypes[:associative_array])
|
|
57
|
-
# :
|
|
57
|
+
# simplecov:disable
|
|
58
58
|
raise "Associated array not yet supported"
|
|
59
|
-
# :
|
|
59
|
+
# simplecov:enable
|
|
60
60
|
elsif type.extends?(BuiltinTypes[:array])
|
|
61
61
|
element_type = type.element_type
|
|
62
62
|
|
|
@@ -62,7 +62,7 @@ module Foobara
|
|
|
62
62
|
|
|
63
63
|
attribute_name = if attribute_name_or_attributes.is_a?(::Hash)
|
|
64
64
|
if attribute_name_or_attributes.keys.size == 1
|
|
65
|
-
attribute_name_or_attributes.keys.
|
|
65
|
+
attribute_name_or_attributes.keys[0].to_sym
|
|
66
66
|
end
|
|
67
67
|
elsif attribute_name_or_attributes
|
|
68
68
|
attribute_name_or_attributes.to_sym
|
|
@@ -75,9 +75,9 @@ module Foobara
|
|
|
75
75
|
transaction = Foobara::Persistence::EntityBase::Transaction.open_transaction_for(self)
|
|
76
76
|
|
|
77
77
|
unless transaction
|
|
78
|
-
# :
|
|
78
|
+
# simplecov:disable
|
|
79
79
|
raise NoCurrentTransactionError, "Trying to load a #{entity_name} outside of a transaction."
|
|
80
|
-
# :
|
|
80
|
+
# simplecov:enable
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
unless transaction.loading?(self)
|
|
@@ -57,7 +57,7 @@ module Foobara
|
|
|
57
57
|
|
|
58
58
|
if load_paths
|
|
59
59
|
if load_paths.is_a?(::Array)
|
|
60
|
-
first = load_paths
|
|
60
|
+
first = load_paths[0]
|
|
61
61
|
|
|
62
62
|
if first.is_a?(::Symbol) || (first.is_a?(::String) && !first.include?("."))
|
|
63
63
|
load_paths = [load_paths]
|
|
@@ -99,8 +99,8 @@ module Foobara
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
def load_many(*record_ids)
|
|
102
|
-
if record_ids.size == 1 && record_ids.
|
|
103
|
-
record_ids = record_ids
|
|
102
|
+
if record_ids.size == 1 && record_ids[0].is_a?(::Array)
|
|
103
|
+
record_ids = record_ids[0]
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
current_transaction_table.load_many(record_ids)
|
|
@@ -125,11 +125,11 @@ module Foobara
|
|
|
125
125
|
|
|
126
126
|
unless containing_records.empty?
|
|
127
127
|
if containing_records.size == 1
|
|
128
|
-
containing_records
|
|
128
|
+
containing_records[0]
|
|
129
129
|
else
|
|
130
|
-
# :
|
|
130
|
+
# simplecov:disable
|
|
131
131
|
raise "Expected only one record to own #{record} but found #{containing_records.size}"
|
|
132
|
-
# :
|
|
132
|
+
# simplecov:enable
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
end
|
|
@@ -155,7 +155,7 @@ module Foobara
|
|
|
155
155
|
end until owning_entity_class
|
|
156
156
|
|
|
157
157
|
if attribute_path.size == 1
|
|
158
|
-
attribute_path = attribute_path
|
|
158
|
+
attribute_path = attribute_path[0]
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
if owning_entity_class == self
|
|
@@ -34,15 +34,15 @@ module Foobara
|
|
|
34
34
|
when 1, 2
|
|
35
35
|
arg, other = args
|
|
36
36
|
|
|
37
|
-
if args.
|
|
37
|
+
if args[0].is_a?(::String)
|
|
38
38
|
[other, arg]
|
|
39
39
|
else
|
|
40
40
|
args
|
|
41
41
|
end
|
|
42
42
|
else
|
|
43
|
-
# :
|
|
43
|
+
# simplecov:disable
|
|
44
44
|
raise ArgumentError, "Too many arguments"
|
|
45
|
-
# :
|
|
45
|
+
# simplecov:enable
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
if model_base_class
|
|
@@ -59,7 +59,7 @@ module Foobara
|
|
|
59
59
|
attributes_type = handler.type_for_declaration(attributes_type_declaration)
|
|
60
60
|
|
|
61
61
|
# TODO: reuse the model_base_class primary key if it has one...
|
|
62
|
-
primary_key = attributes_type.element_types.keys
|
|
62
|
+
primary_key = attributes_type.element_types.keys[0]
|
|
63
63
|
|
|
64
64
|
model_module = unless scoped_full_path.empty?
|
|
65
65
|
scoped_full_name
|
|
@@ -11,9 +11,9 @@ module Foobara
|
|
|
11
11
|
|
|
12
12
|
# rubocop:disable Lint/DuplicateMethods
|
|
13
13
|
def new(...)
|
|
14
|
-
# :
|
|
14
|
+
# simplecov:disable
|
|
15
15
|
raise "Cannot initialize a #{name}. Use .create, .thunk, .loaded, or .build instead."
|
|
16
|
-
# :
|
|
16
|
+
# simplecov:enable
|
|
17
17
|
end
|
|
18
18
|
# rubocop:enable Lint/DuplicateMethods
|
|
19
19
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Foobara
|
|
2
2
|
class Entity < DetachedEntity
|
|
3
|
-
class NotFoundError < Foobara::
|
|
3
|
+
class NotFoundError < Foobara::DataError
|
|
4
4
|
class << self
|
|
5
5
|
def not_found_error_class_name(data_path)
|
|
6
6
|
error_class_name = data_path.path.map { |part| part == :"#" ? "Collection" : Util.classify(part) }.join
|
|
@@ -13,8 +13,8 @@ module Foobara
|
|
|
13
13
|
# TODO: how would we avoid name collisions here??
|
|
14
14
|
Util.make_class("#{mod.name}::#{error_class_name}", self) do
|
|
15
15
|
# TODO: use Concern to change these into attr_accessor instead
|
|
16
|
-
singleton_class.define_method :
|
|
17
|
-
|
|
16
|
+
singleton_class.define_method :symbol do
|
|
17
|
+
:not_found
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
singleton_class.define_method :entity_class do
|
|
@@ -39,7 +39,7 @@ module Foobara
|
|
|
39
39
|
data_path: data_path.to_s
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
new(context:, message:)
|
|
42
|
+
new(context:, message:, path: data_path)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def data_path
|
|
@@ -54,15 +54,15 @@ module Foobara
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def primary_key_attribute
|
|
57
|
-
# :
|
|
57
|
+
# simplecov:disable
|
|
58
58
|
entity_class.primary_key_attribute
|
|
59
|
-
# :
|
|
59
|
+
# simplecov:enable
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def full_entity_name
|
|
63
|
-
# :
|
|
63
|
+
# simplecov:disable
|
|
64
64
|
entity_class.full_entity_name
|
|
65
|
-
# :
|
|
65
|
+
# simplecov:enable
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def criteria
|
|
@@ -8,23 +8,26 @@ module Foobara
|
|
|
8
8
|
elsif record.persisted?
|
|
9
9
|
# We will assume that we do not need to clean up the primary key itself as
|
|
10
10
|
# we will assume we don't allow sensitive primary keys for now.
|
|
11
|
-
thunkish = to_type.target_class.
|
|
11
|
+
thunkish = to_type.target_class.__send__(
|
|
12
|
+
build_method,
|
|
13
|
+
record.class.primary_key_attribute => record.primary_key
|
|
14
|
+
)
|
|
12
15
|
thunkish.skip_validations = true
|
|
13
16
|
thunkish.mutable = false
|
|
14
17
|
thunkish
|
|
15
18
|
else
|
|
16
|
-
# :
|
|
19
|
+
# simplecov:disable
|
|
17
20
|
raise "Not sure what to do with a record that isn't loaded, created, or persisted"
|
|
18
|
-
# :
|
|
21
|
+
# simplecov:enable
|
|
19
22
|
end
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
def build_method
|
|
23
26
|
if to_type.extends?(BuiltinTypes[:entity])
|
|
24
27
|
# TODO: figure out a way to test this path
|
|
25
|
-
# :
|
|
28
|
+
# simplecov:disable
|
|
26
29
|
:build
|
|
27
|
-
# :
|
|
30
|
+
# simplecov:enable
|
|
28
31
|
else
|
|
29
32
|
:new
|
|
30
33
|
end
|
|
@@ -50,9 +50,9 @@ module Foobara
|
|
|
50
50
|
record_id = record_id_for(attributes)
|
|
51
51
|
|
|
52
52
|
unless exists?(record_id)
|
|
53
|
-
# :
|
|
53
|
+
# simplecov:disable
|
|
54
54
|
raise CannotUpdateError.new(record_id, "does not exist")
|
|
55
|
-
# :
|
|
55
|
+
# simplecov:enable
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
records[record_id] = Util.deep_dup(attributes)
|
|
@@ -61,9 +61,9 @@ module Foobara
|
|
|
61
61
|
|
|
62
62
|
def hard_delete(record_id)
|
|
63
63
|
unless exists?(record_id)
|
|
64
|
-
# :
|
|
64
|
+
# simplecov:disable
|
|
65
65
|
raise CannotUpdateError.new(record_id, "does not exist")
|
|
66
|
-
# :
|
|
66
|
+
# simplecov:enable
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
records.delete(record_id)
|
|
@@ -20,7 +20,7 @@ module Foobara
|
|
|
20
20
|
:type_declaration_value_at
|
|
21
21
|
].each do |method_name|
|
|
22
22
|
define_method method_name do |*args, **opts, &block|
|
|
23
|
-
|
|
23
|
+
__send__("foobara_#{method_name}", *args, **opts, &block)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
data/projects/entities/projects/nested_transactionable/lib/foobara/nested_transactionable.rb
CHANGED
|
@@ -34,9 +34,9 @@ module Foobara
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def relevant_entity_classes
|
|
37
|
-
# :
|
|
38
|
-
raise
|
|
39
|
-
# :
|
|
37
|
+
# simplecov:disable
|
|
38
|
+
raise NotImplementedError
|
|
39
|
+
# simplecov:enable
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def transactions
|
|
@@ -118,9 +118,9 @@ module Foobara
|
|
|
118
118
|
if transaction.currently_open?
|
|
119
119
|
# Hard to test this because halting and other exceptions rollback the transactions via
|
|
120
120
|
# block form but to be safe keeping this
|
|
121
|
-
# :
|
|
121
|
+
# simplecov:disable
|
|
122
122
|
transaction.rollback!
|
|
123
|
-
# :
|
|
123
|
+
# simplecov:enable
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
end
|
|
@@ -4,7 +4,7 @@ module Foobara
|
|
|
4
4
|
module Persistence
|
|
5
5
|
class << self
|
|
6
6
|
def reset_all
|
|
7
|
-
Foobara.raise_if_production!
|
|
7
|
+
Foobara.raise_if_production!
|
|
8
8
|
@tables_for_entity_class_name = @bases = @default_crud_driver = @default_base = nil
|
|
9
9
|
EntityBase::Transaction::Concerns::EntityCallbackHandling.reset_all
|
|
10
10
|
EntityBase::Transaction.reset_all
|
|
@@ -78,9 +78,9 @@ module Foobara
|
|
|
78
78
|
match = /^Cannot(\w+)Error$/.match(Util.non_full_name(self.class))
|
|
79
79
|
|
|
80
80
|
unless match
|
|
81
|
-
# :
|
|
81
|
+
# simplecov:disable
|
|
82
82
|
raise "Bad error name for #{self.class.name}"
|
|
83
|
-
# :
|
|
83
|
+
# simplecov:enable
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
Util.underscore(match[1])
|
|
@@ -121,15 +121,15 @@ module Foobara
|
|
|
121
121
|
|
|
122
122
|
# CRUD
|
|
123
123
|
def select(_query_declaration)
|
|
124
|
-
# :
|
|
125
|
-
raise
|
|
126
|
-
# :
|
|
124
|
+
# simplecov:disable
|
|
125
|
+
raise NotImplementedError
|
|
126
|
+
# simplecov:enable
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
def all(page_size: nil)
|
|
130
|
-
# :
|
|
131
|
-
raise
|
|
132
|
-
# :
|
|
130
|
+
# simplecov:disable
|
|
131
|
+
raise NotImplementedError
|
|
132
|
+
# simplecov:enable
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
def first
|
|
@@ -137,9 +137,9 @@ module Foobara
|
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
def find(_record_id)
|
|
140
|
-
# :
|
|
141
|
-
raise
|
|
142
|
-
# :
|
|
140
|
+
# simplecov:disable
|
|
141
|
+
raise NotImplementedError
|
|
142
|
+
# simplecov:enable
|
|
143
143
|
end
|
|
144
144
|
|
|
145
145
|
def find!(record_id)
|
|
@@ -184,9 +184,7 @@ module Foobara
|
|
|
184
184
|
|
|
185
185
|
def find_all_by_attribute_containing_any_of(attribute_name, values)
|
|
186
186
|
all.select do |attributes|
|
|
187
|
-
attributes[attribute_name]&.
|
|
188
|
-
values.include?(attribute_value)
|
|
189
|
-
end
|
|
187
|
+
attributes[attribute_name]&.intersect?(values)
|
|
190
188
|
end
|
|
191
189
|
end
|
|
192
190
|
|
|
@@ -228,51 +226,51 @@ module Foobara
|
|
|
228
226
|
end
|
|
229
227
|
|
|
230
228
|
def insert(_attributes)
|
|
231
|
-
# :
|
|
232
|
-
raise
|
|
233
|
-
# :
|
|
229
|
+
# simplecov:disable
|
|
230
|
+
raise NotImplementedError
|
|
231
|
+
# simplecov:enable
|
|
234
232
|
end
|
|
235
233
|
|
|
236
234
|
def insert_many(attributes_array)
|
|
237
235
|
# TODO: add a test for a driver that doesn't override this and remove these :nocov: comments
|
|
238
|
-
# :
|
|
236
|
+
# simplecov:disable
|
|
239
237
|
attributes_array.each.lazy.map do |attributes|
|
|
240
238
|
insert(attributes)
|
|
241
239
|
end
|
|
242
|
-
# :
|
|
240
|
+
# simplecov:enable
|
|
243
241
|
end
|
|
244
242
|
|
|
245
243
|
def update(_record)
|
|
246
|
-
# :
|
|
247
|
-
raise
|
|
248
|
-
# :
|
|
244
|
+
# simplecov:disable
|
|
245
|
+
raise NotImplementedError
|
|
246
|
+
# simplecov:enable
|
|
249
247
|
end
|
|
250
248
|
|
|
251
249
|
def hard_delete(_record_id)
|
|
252
|
-
# :
|
|
253
|
-
raise
|
|
254
|
-
# :
|
|
250
|
+
# simplecov:disable
|
|
251
|
+
raise NotImplementedError
|
|
252
|
+
# simplecov:enable
|
|
255
253
|
end
|
|
256
254
|
|
|
257
255
|
def hard_delete_many(record_ids)
|
|
258
256
|
# TODO: add a test for a driver that doesn't override this and remove these :nocov: comments
|
|
259
|
-
# :
|
|
257
|
+
# simplecov:disable
|
|
260
258
|
record_ids.each.lazy.map do |record_id|
|
|
261
259
|
delete(record_id)
|
|
262
260
|
end
|
|
263
|
-
# :
|
|
261
|
+
# simplecov:enable
|
|
264
262
|
end
|
|
265
263
|
|
|
266
264
|
def hard_delete_all!
|
|
267
|
-
# :
|
|
268
|
-
raise
|
|
269
|
-
# :
|
|
265
|
+
# simplecov:disable
|
|
266
|
+
raise NotImplementedError
|
|
267
|
+
# simplecov:enable
|
|
270
268
|
end
|
|
271
269
|
|
|
272
270
|
def count
|
|
273
|
-
# :
|
|
274
|
-
raise
|
|
275
|
-
# :
|
|
271
|
+
# simplecov:disable
|
|
272
|
+
raise NotImplementedError
|
|
273
|
+
# simplecov:enable
|
|
276
274
|
end
|
|
277
275
|
|
|
278
276
|
def exists?(record_id)
|
|
@@ -301,12 +299,12 @@ module Foobara
|
|
|
301
299
|
end
|
|
302
300
|
elsif type.extends?(BuiltinTypes[:tuple])
|
|
303
301
|
# TODO: test this code path
|
|
304
|
-
# :
|
|
302
|
+
# simplecov:disable
|
|
305
303
|
object.map.with_index do |value, index|
|
|
306
304
|
element_type = type.element_types[index]
|
|
307
305
|
restore_attributes(value, element_type)
|
|
308
306
|
end
|
|
309
|
-
# :
|
|
307
|
+
# simplecov:enable
|
|
310
308
|
elsif type.extends?(BuiltinTypes[:array])
|
|
311
309
|
element_type = type.element_type
|
|
312
310
|
object.map { |value| restore_attributes(value, element_type) }
|
|
@@ -333,9 +331,9 @@ module Foobara
|
|
|
333
331
|
outcome.result
|
|
334
332
|
else
|
|
335
333
|
# TODO: figure out how to test this code path
|
|
336
|
-
# :
|
|
334
|
+
# simplecov:disable
|
|
337
335
|
object
|
|
338
|
-
# :
|
|
336
|
+
# simplecov:enable
|
|
339
337
|
end
|
|
340
338
|
end
|
|
341
339
|
end
|