convenient_service 0.10.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dev/.tmuxinator.yml +2 -1
- data/.github/workflows/ci.yml +21 -1
- data/CHANGELOG.md +90 -0
- data/Gemfile +6 -0
- data/README.md +4 -2
- data/Taskfile.yml +94 -0
- data/convenient_service.gemspec +40 -2
- data/docker/2.7/Dockerfile +3 -3
- data/docker/3.0/Dockerfile +2 -2
- data/docker/3.1/Dockerfile +2 -2
- data/docker/3.2/Dockerfile +73 -0
- data/docker/jruby-9.4/Dockerfile +88 -0
- data/docker/truffleruby-22.3/Dockerfile +91 -0
- data/lib/convenient_service/common/plugins/aliases.rb +0 -1
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_active_model_attribute_assignment/middleware.rb +12 -8
- data/lib/convenient_service/common/plugins/caches_return_value/middleware.rb +3 -3
- data/lib/convenient_service/common/plugins/can_have_user_provided_entity/errors.rb +2 -2
- data/lib/convenient_service/common/plugins/has_around_callbacks/errors.rb +1 -1
- data/lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb +7 -7
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/aliases.rb +7 -0
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins.rb +2 -0
- data/lib/convenient_service/configs/minimal.rb +23 -4
- data/lib/convenient_service/configs/standard.rb +0 -4
- data/lib/convenient_service/core/class_methods.rb +24 -9
- data/lib/convenient_service/core/constants.rb +36 -0
- data/lib/convenient_service/core/entities/config/commands/track_method_missing_commit_trigger.rb +69 -0
- data/lib/convenient_service/core/entities/config/commands.rb +3 -0
- data/lib/convenient_service/core/entities/config/entities/concerns/entities/stack.rb +10 -10
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb +3 -3
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middleware.rb +18 -1
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middleware_creator.rb +62 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/stack.rb +12 -12
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities.rb +1 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares.rb +1 -1
- data/lib/convenient_service/core/entities/config/errors.rb +38 -1
- data/lib/convenient_service/core/entities/config.rb +14 -4
- data/lib/convenient_service/core/instance_methods.rb +6 -4
- data/lib/convenient_service/core.rb +1 -0
- data/lib/convenient_service/dependencies/built_in.rb +7 -0
- data/lib/convenient_service/dependencies/extractions/active_support_concern/concern.rb +18 -2
- data/lib/convenient_service/dependencies/extractions/active_support_concern.rb +4 -0
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/builder.rb +7 -1
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/logger.rb +7 -1
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/runner.rb +15 -1
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware.rb +8 -1
- data/lib/convenient_service/dependencies/extractions/ruby_middleware.rb +3 -2
- data/lib/convenient_service/dependencies.rb +16 -15
- data/lib/convenient_service/examples/dry/gemfile.rb +4 -4
- data/lib/convenient_service/examples/rails/gemfile.rb +4 -4
- data/lib/convenient_service/examples/standard/cowsay.rb +4 -4
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb +1 -1
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_not_empty.rb +1 -1
- data/lib/convenient_service/examples/standard/gemfile/services/assert_node_available.rb +0 -9
- data/lib/convenient_service/examples/standard/gemfile.rb +4 -4
- data/lib/convenient_service/examples/standard/request_params.rb +4 -4
- data/lib/convenient_service/feature.rb +12 -0
- data/lib/convenient_service/logger.rb +6 -5
- data/lib/convenient_service/rspec/helpers/custom/in_threads.rb +74 -0
- data/lib/convenient_service/rspec/helpers/custom/stub_service/constants.rb +20 -0
- data/lib/convenient_service/rspec/helpers/custom/stub_service/entities/stubbed_service.rb +4 -4
- data/lib/convenient_service/rspec/helpers/custom/stub_service.rb +1 -0
- data/lib/convenient_service/rspec/helpers/custom/wrap_method/entities/wrapped_method.rb +3 -3
- data/lib/convenient_service/rspec/helpers/custom/wrap_method/errors.rb +1 -1
- data/lib/convenient_service/rspec/helpers/custom.rb +1 -0
- data/lib/convenient_service/rspec/helpers/in_threads.rb +13 -0
- data/lib/convenient_service/rspec/helpers.rb +2 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings_collection/errors.rb +3 -3
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/delegation.rb +3 -3
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher.rb +2 -2
- data/lib/convenient_service/rspec/matchers/custom/export.rb +82 -0
- data/lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_method_step.rb +4 -4
- data/lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_result_method_step.rb +4 -4
- data/lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_service_step.rb +1 -1
- data/lib/convenient_service/rspec/matchers/custom/results/base/constants.rb +22 -0
- data/lib/convenient_service/rspec/matchers/custom/results/base/errors.rb +1 -1
- data/lib/convenient_service/rspec/matchers/custom/results/base.rb +2 -1
- data/lib/convenient_service/rspec/matchers/custom.rb +1 -0
- data/lib/convenient_service/rspec/matchers/export.rb +13 -0
- data/lib/convenient_service/rspec/matchers.rb +2 -0
- data/lib/convenient_service/service/plugins/aliases.rb +0 -2
- data/lib/convenient_service/service/plugins/{has_result_method_steps → can_have_method_steps}/middleware.rb +12 -2
- data/lib/convenient_service/service/plugins/can_have_method_steps.rb +3 -0
- data/lib/convenient_service/service/plugins/can_have_result_step/middleware.rb +43 -0
- data/lib/convenient_service/service/plugins/can_have_result_step.rb +3 -0
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/commands/create_step_class.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/concern.rb +10 -10
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method.rb +92 -0
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/commands/cast_method_direction.rb +30 -3
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_factory.rb +113 -0
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/commands/define_method_in_container.rb +3 -3
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/commands.rb +1 -3
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/concern/class_methods.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/concern/instance_methods.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/alias.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/base.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/proc.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/raw.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/reassignment/commands/define_method_in_container.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/reassignment.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/usual.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/directions/base.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/directions/input.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/directions/output.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/base.rb +62 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/base.rb +35 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/proc_value.rb +42 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/raw_value.rb +42 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/reassignment_value.rb +42 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/string_value.rb +42 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/symbol_value.rb +42 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash.rb +8 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/method.rb +40 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/reassignment.rb +40 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/string.rb +40 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/symbol.rb +40 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories.rb +8 -0
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/key.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/name.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/values/reassignment.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities.rb +1 -0
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/errors.rb +8 -8
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/service/class_methods.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/service.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/commands/cast_params.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/commands/extract_params.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/concern/instance_methods.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/errors.rb +27 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/aliases.rb +7 -0
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/plugins/can_have_parent_result/middleware.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/plugins/has_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/plugins.rb +2 -0
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/structs/params.rb +1 -1
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb +106 -0
- data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/middleware.rb +4 -4
- data/lib/convenient_service/service/plugins/can_have_steps.rb +6 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb +19 -11
- data/lib/convenient_service/service/plugins/can_have_stubbed_result/middleware.rb +3 -3
- data/lib/convenient_service/service/plugins/has_result/concern/instance_methods.rb +3 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/aliases.rb +7 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/concern.rb +12 -5
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes/concern/class_methods.rb → can_have_parent_result/constants.rb} +3 -4
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result.rb +1 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes/commands/cast_jsend_attributes.rb → has_j_send_status_and_attributes/commands/cast_j_send_attributes.rb} +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_code_class.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_data_class.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_message_class.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_status_class.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands.rb +7 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/concern/class_methods.rb +69 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/concern/instance_methods.rb +9 -9
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities/code/concern/class_methods.rb +2 -2
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities/code/concern/instance_methods.rb +3 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities/code/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities/code.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/class_methods.rb +38 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb +94 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern.rb +36 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data.rb +25 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/concern/class_methods.rb +40 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/concern/instance_methods.rb +58 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/concern.rb +36 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message.rb +25 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern/class_methods.rb +40 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern/instance_methods.rb +115 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern.rb +36 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status.rb +25 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/errors.rb +6 -2
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/middleware.rb +4 -4
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes/structs/jsend_attributes.rb → has_j_send_status_and_attributes/structs/j_send_attributes.rb} +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/structs.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes.rb +8 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax/concern.rb +3 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/raises_on_not_checked_result_status/errors.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins.rb +3 -1
- data/lib/convenient_service/service/plugins/has_result/errors.rb +2 -2
- data/lib/convenient_service/service/plugins/has_result_status_check_short_syntax/concern.rb +16 -0
- data/lib/convenient_service/service/plugins/raises_on_double_result/errors.rb +1 -1
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb +1 -1
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_exception.rb +11 -10
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb +14 -7
- data/lib/convenient_service/service/plugins.rb +3 -2
- data/lib/convenient_service/services/run_own_method_in_organizer.rb +1 -1
- data/lib/convenient_service/support/abstract_method/errors.rb +1 -1
- data/lib/convenient_service/support/arguments.rb +3 -3
- data/lib/convenient_service/support/cache/key.rb +3 -3
- data/lib/convenient_service/support/cache.rb +1 -1
- data/lib/convenient_service/support/castable/errors.rb +2 -2
- data/lib/convenient_service/support/counter.rb +212 -0
- data/lib/convenient_service/support/dependency_container/commands/assert_valid_container.rb +33 -0
- data/lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb +58 -0
- data/lib/convenient_service/support/dependency_container/commands/assert_valid_scope.rb +4 -3
- data/lib/convenient_service/support/dependency_container/commands/define_entry.rb +49 -0
- data/lib/convenient_service/support/dependency_container/commands.rb +3 -0
- data/lib/convenient_service/support/dependency_container/container.rb +23 -0
- data/lib/convenient_service/support/dependency_container/entry.rb +22 -0
- data/lib/convenient_service/support/dependency_container/errors.rb +5 -5
- data/lib/convenient_service/support/dependency_container/import.rb +3 -3
- data/lib/convenient_service/support/dependency_container.rb +3 -0
- data/lib/convenient_service/support/finite_loop.rb +37 -2
- data/lib/convenient_service/support/middleware/stack_builder.rb +1 -1
- data/lib/convenient_service/support/not_passed.rb +4 -3
- data/lib/convenient_service/support/ruby.rb +31 -0
- data/lib/convenient_service/support/safe_method.rb +65 -0
- data/lib/convenient_service/support/thread_safe_counter.rb +119 -0
- data/lib/convenient_service/support/undefined.rb +4 -3
- data/lib/convenient_service/support/unique_value.rb +69 -0
- data/lib/convenient_service/support.rb +4 -0
- data/lib/convenient_service/utils/array/errors.rb +1 -1
- data/lib/convenient_service/utils/array/find_last.rb +1 -1
- data/lib/convenient_service/utils/array/find_yield.rb +1 -1
- data/lib/convenient_service/utils/object/resolve_class.rb +56 -0
- data/lib/convenient_service/utils/object.rb +9 -0
- data/lib/convenient_service/version.rb +1 -1
- data/lib/convenient_service.rb +6 -0
- metadata +129 -86
- data/lib/convenient_service/factories/arguments.rb +0 -43
- data/lib/convenient_service/factories/results.rb +0 -214
- data/lib/convenient_service/factories/services.rb +0 -189
- data/lib/convenient_service/factories/step/instance.rb +0 -32
- data/lib/convenient_service/factories/step.rb +0 -3
- data/lib/convenient_service/factories/steps.rb +0 -126
- data/lib/convenient_service/factories.rb +0 -22
- data/lib/convenient_service/factory.rb +0 -21
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands.rb +0 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data/class_methods.rb +0 -32
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data.rb +0 -74
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message/class_methods.rb +0 -34
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message.rb +0 -45
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status/class_methods.rb +0 -34
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb +0 -77
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs.rb +0 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes.rb +0 -8
- data/lib/convenient_service/service/plugins/has_result_method_steps.rb +0 -3
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method.rb +0 -57
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_caller.rb +0 -74
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_key.rb +0 -78
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_name.rb +0 -78
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/errors.rb +0 -23
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb +0 -77
- data/lib/convenient_service/service/plugins/has_result_steps.rb +0 -6
- /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/commands.rb +0 -0
- /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/reassignment/commands.rb +0 -0
- /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers.rb +0 -0
- /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/directions.rb +0 -0
- /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/values.rb +0 -0
- /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/commands.rb +0 -0
- /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/plugins/can_have_parent_result.rb +0 -0
- /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/plugins/has_inspect.rb +0 -0
- /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/structs.rb +0 -0
- /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities.rb +0 -0
- /data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities.rb +0 -0
@@ -55,6 +55,22 @@ module ConvenientService
|
|
55
55
|
def not_failure?(...)
|
56
56
|
result(...).not_failure?
|
57
57
|
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# @return [Boolean]
|
61
|
+
# @since 0.12.0
|
62
|
+
#
|
63
|
+
def ok?(...)
|
64
|
+
result(...).success?
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# @return [Boolean]
|
69
|
+
# @since 0.12.0
|
70
|
+
#
|
71
|
+
def not_ok?(...)
|
72
|
+
result(...).not_success?
|
73
|
+
end
|
58
74
|
end
|
59
75
|
end
|
60
76
|
end
|
@@ -5,7 +5,7 @@ module ConvenientService
|
|
5
5
|
module Plugins
|
6
6
|
module RaisesOnDoubleResult
|
7
7
|
module Errors
|
8
|
-
class DoubleResult < ConvenientService::Error
|
8
|
+
class DoubleResult < ::ConvenientService::Error
|
9
9
|
def initialize(service:)
|
10
10
|
message = <<~TEXT
|
11
11
|
`#{service.class}` service has a double result.
|
@@ -28,7 +28,7 @@ module ConvenientService
|
|
28
28
|
# - https://blog.kalina.tech/2019/04/exception-without-backtrace-in-ruby.html
|
29
29
|
# - https://github.com/jruby/jruby/issues/4467
|
30
30
|
#
|
31
|
-
def initialize(backtrace:, max_size:)
|
31
|
+
def initialize(backtrace:, max_size: Constants::DEFAULT_MAX_BACKTRACE_SIZE)
|
32
32
|
@backtrace = backtrace.to_a
|
33
33
|
@max_size = max_size
|
34
34
|
end
|
@@ -12,6 +12,12 @@ module ConvenientService
|
|
12
12
|
#
|
13
13
|
attr_reader :exception
|
14
14
|
|
15
|
+
##
|
16
|
+
# @!attribute [r] max_backtrace_size
|
17
|
+
# @return [Integer]
|
18
|
+
#
|
19
|
+
attr_reader :max_backtrace_size
|
20
|
+
|
15
21
|
##
|
16
22
|
# @!attribute [r] args
|
17
23
|
# @return [StandardError]
|
@@ -32,16 +38,18 @@ module ConvenientService
|
|
32
38
|
|
33
39
|
##
|
34
40
|
# @param exception [StandardError]
|
35
|
-
# @param args [Array]
|
36
|
-
# @param kwargs [Hash]
|
41
|
+
# @param args [Array<Object>]
|
42
|
+
# @param kwargs [Hash{Symbol => Object}]
|
37
43
|
# @param block [Proc, nil]
|
44
|
+
# @param max_backtrace_size [Integer]
|
38
45
|
# @return [void]
|
39
46
|
#
|
40
|
-
def initialize(exception:, args:, kwargs:, block:)
|
47
|
+
def initialize(exception:, args:, kwargs:, block:, max_backtrace_size: Constants::DEFAULT_MAX_BACKTRACE_SIZE)
|
41
48
|
@exception = exception
|
42
49
|
@args = args
|
43
50
|
@kwargs = kwargs
|
44
51
|
@block = block
|
52
|
+
@max_backtrace_size = max_backtrace_size
|
45
53
|
end
|
46
54
|
|
47
55
|
##
|
@@ -179,13 +187,6 @@ module ConvenientService
|
|
179
187
|
def formatted_exception_cause
|
180
188
|
Commands::FormatCause.call(cause: exception.cause)
|
181
189
|
end
|
182
|
-
|
183
|
-
##
|
184
|
-
# @return [Integer]
|
185
|
-
#
|
186
|
-
def max_backtrace_size
|
187
|
-
Constants::DEFAULT_MAX_BACKTRACE_SIZE
|
188
|
-
end
|
189
190
|
end
|
190
191
|
end
|
191
192
|
end
|
data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb
CHANGED
@@ -6,8 +6,8 @@ module ConvenientService
|
|
6
6
|
module RescuesResultUnhandledExceptions
|
7
7
|
class Middleware < Core::MethodChainMiddleware
|
8
8
|
##
|
9
|
-
# @param args [Array]
|
10
|
-
# @param kwargs [Hash]
|
9
|
+
# @param args [Array<Object>]
|
10
|
+
# @param kwargs [Hash{Symbol => Object}]
|
11
11
|
# @param block [Proc, nil]
|
12
12
|
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result]
|
13
13
|
#
|
@@ -29,8 +29,8 @@ module ConvenientService
|
|
29
29
|
|
30
30
|
##
|
31
31
|
# @param exception [StandardError]
|
32
|
-
# @param args [Array]
|
33
|
-
# @param kwargs [Hash]
|
32
|
+
# @param args [Array<Object>]
|
33
|
+
# @param kwargs [Hash{Symbol => Object}]
|
34
34
|
# @param block [Proc, nil]
|
35
35
|
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result]
|
36
36
|
#
|
@@ -43,13 +43,20 @@ module ConvenientService
|
|
43
43
|
|
44
44
|
##
|
45
45
|
# @param exception [StandardError]
|
46
|
-
# @param args [Array]
|
47
|
-
# @param kwargs [Hash]
|
46
|
+
# @param args [Array<Object>]
|
47
|
+
# @param kwargs [Hash{Symbol => Object}]
|
48
48
|
# @param block [Proc, nil]
|
49
49
|
# @return [String]
|
50
50
|
#
|
51
51
|
def format_exception(exception, *args, **kwargs, &block)
|
52
|
-
Commands::FormatException.call(exception: exception, args: args, kwargs: kwargs, block: block)
|
52
|
+
Commands::FormatException.call(exception: exception, args: args, kwargs: kwargs, block: block, max_backtrace_size: max_backtrace_size)
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# @return [Integer]
|
57
|
+
#
|
58
|
+
def max_backtrace_size
|
59
|
+
arguments.kwargs.fetch(:max_backtrace_size) { Constants::DEFAULT_MAX_BACKTRACE_SIZE }
|
53
60
|
end
|
54
61
|
end
|
55
62
|
end
|
@@ -4,12 +4,13 @@
|
|
4
4
|
# NOTE: Order matters.
|
5
5
|
#
|
6
6
|
require_relative "plugins/can_recalculate_result"
|
7
|
+
require_relative "plugins/can_have_method_steps"
|
8
|
+
require_relative "plugins/can_have_result_step"
|
9
|
+
require_relative "plugins/can_have_steps"
|
7
10
|
require_relative "plugins/can_have_stubbed_result"
|
8
11
|
require_relative "plugins/has_inspect"
|
9
12
|
require_relative "plugins/has_result"
|
10
|
-
require_relative "plugins/has_result_method_steps"
|
11
13
|
require_relative "plugins/has_result_short_syntax"
|
12
|
-
require_relative "plugins/has_result_steps"
|
13
14
|
require_relative "plugins/raises_on_double_result"
|
14
15
|
require_relative "plugins/wraps_result_in_db_transaction"
|
15
16
|
require_relative "plugins/has_result_status_check_short_syntax"
|
@@ -4,7 +4,7 @@ module ConvenientService
|
|
4
4
|
module Services
|
5
5
|
class RunOwnMethodInOrganizer
|
6
6
|
module Errors
|
7
|
-
class MethodForStepIsNotDefined < ConvenientService::Error
|
7
|
+
class MethodForStepIsNotDefined < ::ConvenientService::Error
|
8
8
|
def initialize(service_class:, method_name:)
|
9
9
|
message = <<~TEXT
|
10
10
|
Service #{service_class} tries to use `#{method_name}` method in a step, but it NOT defined.
|
@@ -4,7 +4,7 @@ module ConvenientService
|
|
4
4
|
module Support
|
5
5
|
module AbstractMethod
|
6
6
|
module Errors
|
7
|
-
class AbstractMethodNotOverridden < ::
|
7
|
+
class AbstractMethodNotOverridden < ::ConvenientService::Error
|
8
8
|
def initialize(instance:, method:)
|
9
9
|
klass = instance.is_a?(::Class) ? instance : instance.class
|
10
10
|
method_type = Utils::Object.resolve_type(instance)
|
@@ -24,9 +24,9 @@ module ConvenientService
|
|
24
24
|
attr_reader :block
|
25
25
|
|
26
26
|
##
|
27
|
-
# @param args [Array]
|
28
|
-
# @param kwargs [Hash]
|
29
|
-
# @param block [Proc]
|
27
|
+
# @param args [Array<Object>]
|
28
|
+
# @param kwargs [Hash{Symbol => Object}]
|
29
|
+
# @param block [Proc, nil]
|
30
30
|
# @return [void]
|
31
31
|
#
|
32
32
|
def initialize(*args, **kwargs, &block)
|
@@ -5,9 +5,9 @@ module ConvenientService
|
|
5
5
|
class Cache
|
6
6
|
class Key
|
7
7
|
##
|
8
|
-
# @param args [Array]
|
9
|
-
# @param kwargs [Hash]
|
10
|
-
# @param block [Proc]
|
8
|
+
# @param args [Array<Object>]
|
9
|
+
# @param kwargs [Hash{Symbol => Object}]
|
10
|
+
# @param block [Proc, nil]
|
11
11
|
# @return [void]
|
12
12
|
#
|
13
13
|
def initialize(*args, **kwargs, &block)
|
@@ -4,7 +4,7 @@ module ConvenientService
|
|
4
4
|
module Support
|
5
5
|
module Castable
|
6
6
|
module Errors
|
7
|
-
class CastIsNotOverridden < ::
|
7
|
+
class CastIsNotOverridden < ::ConvenientService::Error
|
8
8
|
def initialize(klass:)
|
9
9
|
message = <<~TEXT
|
10
10
|
Cast method (.cast) of `#{klass}` is NOT overridden.
|
@@ -14,7 +14,7 @@ module ConvenientService
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
class FailedToCast < ::
|
17
|
+
class FailedToCast < ::ConvenientService::Error
|
18
18
|
def initialize(other:, klass:)
|
19
19
|
message = <<~TEXT
|
20
20
|
Failed to cast `#{other.inspect}` into `#{klass}`.
|
@@ -0,0 +1,212 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Support
|
5
|
+
##
|
6
|
+
# @internal
|
7
|
+
# NOTE: `return` exits from the enclosing method. `break` from the iterator method. `next` from the block.
|
8
|
+
# - https://github.com/ruby/spec/blob/master/language/return_spec.rb
|
9
|
+
# - https://github.com/ruby/spec/blob/master/language/break_spec.rb
|
10
|
+
# - https://github.com/ruby/spec/blob/master/language/next_spec.rb
|
11
|
+
# - https://stackoverflow.com/a/1402764/12201472
|
12
|
+
#
|
13
|
+
class Counter
|
14
|
+
module Errors
|
15
|
+
class ValueAfterIncrementIsGreaterThanMaxValue < ::ConvenientService::Error
|
16
|
+
##
|
17
|
+
# @param n [Integer]
|
18
|
+
# @param current_value [Integer]
|
19
|
+
# @param max_value [Integer]
|
20
|
+
# @return [void]
|
21
|
+
#
|
22
|
+
def initialize(n:, current_value:, max_value:)
|
23
|
+
message = <<~TEXT
|
24
|
+
Value after increment by `#{n}` is greater than the max value.
|
25
|
+
|
26
|
+
Current value is `#{current_value}`.
|
27
|
+
|
28
|
+
Max value is `#{max_value}`.
|
29
|
+
TEXT
|
30
|
+
|
31
|
+
super(message)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class ValueAfterDecrementIsLowerThanMinValue < ::ConvenientService::Error
|
36
|
+
##
|
37
|
+
# @param n [Integer]
|
38
|
+
# @param current_value [Integer]
|
39
|
+
# @param min_value [Integer]
|
40
|
+
# @return [void]
|
41
|
+
#
|
42
|
+
def initialize(n:, current_value:, min_value:)
|
43
|
+
message = <<~TEXT
|
44
|
+
Value after decrement by `#{n}` is lower than the min value.
|
45
|
+
|
46
|
+
Current value is `#{current_value}`.
|
47
|
+
|
48
|
+
Min value is `#{min_value}`.
|
49
|
+
TEXT
|
50
|
+
|
51
|
+
super(message)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# @!attribute [r] initial_value
|
58
|
+
# @return [Integer]
|
59
|
+
#
|
60
|
+
attr_reader :initial_value
|
61
|
+
|
62
|
+
##
|
63
|
+
# @!attribute [rw] current_value
|
64
|
+
# @return [Integer]
|
65
|
+
#
|
66
|
+
attr_accessor :current_value
|
67
|
+
|
68
|
+
##
|
69
|
+
# @!attribute [r] min_value
|
70
|
+
# @return [Integer, Float::INFINITY]
|
71
|
+
#
|
72
|
+
attr_reader :min_value
|
73
|
+
|
74
|
+
##
|
75
|
+
# @!attribute [r] max_value
|
76
|
+
# @return [Integer, Float::INFINITY]
|
77
|
+
#
|
78
|
+
attr_reader :max_value
|
79
|
+
|
80
|
+
##
|
81
|
+
# @param initial_value [Integer]
|
82
|
+
# @param min_value [Integer, -::Float::Infinity]
|
83
|
+
# @param max_value [Integer, Float::Infinity]
|
84
|
+
# @return [void]
|
85
|
+
#
|
86
|
+
# @note Do NOT rely on the fact that `min_value` and `max_value` are almost always `Integer` instances since they are set to `-Float::INFINITY` and `Float::INFINITY` by default.
|
87
|
+
# @note `Float::INFINITY` and `Integer` are just contextual ducks, NOT full ducks. For example, `Float::INFINITY.to_i` raises `FloatDomainError`.
|
88
|
+
#
|
89
|
+
def initialize(initial_value: 0, min_value: -::Float::INFINITY, max_value: ::Float::INFINITY)
|
90
|
+
@initial_value = initial_value
|
91
|
+
@current_value = initial_value
|
92
|
+
@min_value = min_value
|
93
|
+
@max_value = max_value
|
94
|
+
@lock = ::Mutex.new
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# @param n [Integer]
|
99
|
+
# @return [Integer]
|
100
|
+
#
|
101
|
+
# @internal
|
102
|
+
# NOTE: Instance variables are accessed directly to release the lock faster.
|
103
|
+
#
|
104
|
+
# NOTE: The name is inspired by Redis and Concurrent Ruby.
|
105
|
+
# - https://redis.io/commands/incr/
|
106
|
+
# - https://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/AtomicFixnum.html#increment-instance_method
|
107
|
+
#
|
108
|
+
def increment(n = 1)
|
109
|
+
return @current_value if @current_value + n > @max_value
|
110
|
+
|
111
|
+
@current_value += n
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# @param n [Integer]
|
116
|
+
# @return [Integer]
|
117
|
+
# @raise [ConvenientService::Support::ThreadSafeCounter::Errors::ValueAfterIncrementIsGreaterThanMaxValue]
|
118
|
+
#
|
119
|
+
# @internal
|
120
|
+
# NOTE: Instance variables are accessed directly to release the lock faster.
|
121
|
+
#
|
122
|
+
# NOTE: The name is inspired by Rails.
|
123
|
+
# - https://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-save
|
124
|
+
# - https://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-save-21
|
125
|
+
#
|
126
|
+
def increment!(n = 1)
|
127
|
+
raise Errors::ValueAfterIncrementIsGreaterThanMaxValue.new(n: n, current_value: @current_value, max_value: @max_value) if @current_value + n > @max_value
|
128
|
+
|
129
|
+
@current_value += n
|
130
|
+
end
|
131
|
+
|
132
|
+
##
|
133
|
+
# `bincrement` means boolean increment. Works exactly in the same way as `increment` except returns a boolean value.
|
134
|
+
# If incremented successfully then returns `true`, otherwise - returns `false`.
|
135
|
+
#
|
136
|
+
# @param n [Integer]
|
137
|
+
# @return [Boolean]
|
138
|
+
#
|
139
|
+
# @internal
|
140
|
+
# NOTE: Instance variables are accessed directly to release the lock faster.
|
141
|
+
#
|
142
|
+
def bincrement(n = 1)
|
143
|
+
return false if @current_value + n > @max_value
|
144
|
+
|
145
|
+
@current_value += n
|
146
|
+
|
147
|
+
true
|
148
|
+
end
|
149
|
+
|
150
|
+
##
|
151
|
+
# @param n [Integer]
|
152
|
+
# @return [Integer]
|
153
|
+
#
|
154
|
+
# @internal
|
155
|
+
# NOTE: Instance variables are accessed directly to release the lock faster.
|
156
|
+
#
|
157
|
+
# NOTE: The name is inspired by Redis and Concurrent Ruby.
|
158
|
+
# - https://redis.io/commands/decr/
|
159
|
+
# - https://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/AtomicFixnum.html#decrement-instance_method
|
160
|
+
#
|
161
|
+
def decrement(n = 1)
|
162
|
+
return @current_value if @current_value - n < @min_value
|
163
|
+
|
164
|
+
@current_value -= n
|
165
|
+
end
|
166
|
+
|
167
|
+
##
|
168
|
+
# @param n [Integer]
|
169
|
+
# @return [Integer]
|
170
|
+
# @raise [ConvenientService::Support::ThreadSafeCounter::Errors::ValueAfterDecrementIsLowerThanMinValue]
|
171
|
+
#
|
172
|
+
# @internal
|
173
|
+
# NOTE: Instance variables are accessed directly to release the lock faster.
|
174
|
+
#
|
175
|
+
# NOTE: The name is inspired by Rails.
|
176
|
+
# - https://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-save
|
177
|
+
# - https://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-save-21
|
178
|
+
#
|
179
|
+
def decrement!(n = 1)
|
180
|
+
raise Errors::ValueAfterDecrementIsLowerThanMinValue.new(n: n, current_value: @current_value, min_value: @min_value) if @current_value - n < @min_value
|
181
|
+
|
182
|
+
@current_value -= n
|
183
|
+
end
|
184
|
+
|
185
|
+
##
|
186
|
+
# `bdecrement` means boolean decrement. Works exactly in the same way as `decrement` except returns a boolean value.
|
187
|
+
# If decremented successfully then returns `true`, otherwise - returns `false`.
|
188
|
+
#
|
189
|
+
# @param n [Integer]
|
190
|
+
# @return [Boolean]
|
191
|
+
#
|
192
|
+
# @internal
|
193
|
+
# NOTE: Instance variables are accessed directly to release the lock faster.
|
194
|
+
#
|
195
|
+
def bdecrement(n = 1)
|
196
|
+
return false if @current_value - n < @min_value
|
197
|
+
|
198
|
+
@current_value -= n
|
199
|
+
|
200
|
+
true
|
201
|
+
end
|
202
|
+
|
203
|
+
##
|
204
|
+
# @internal
|
205
|
+
# NOTE: Instance variables are accessed directly to release the lock faster.
|
206
|
+
#
|
207
|
+
def reset
|
208
|
+
@current_value = @initial_value
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Support
|
5
|
+
module DependencyContainer
|
6
|
+
module Commands
|
7
|
+
class AssertValidContainer < Support::Command
|
8
|
+
##
|
9
|
+
# @!attribute [r] container
|
10
|
+
# @return [Module]
|
11
|
+
#
|
12
|
+
attr_reader :container
|
13
|
+
|
14
|
+
##
|
15
|
+
# @param container [Module]
|
16
|
+
# @return [void]
|
17
|
+
#
|
18
|
+
def initialize(container:)
|
19
|
+
@container = container
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# @return [void]
|
24
|
+
# @raise [ConvenientService::Support::DependencyContainer::Errors::NotExportableModule]
|
25
|
+
#
|
26
|
+
def call
|
27
|
+
raise Errors::NotExportableModule.new(mod: container) unless Utils::Module.include_module?(container, DependencyContainer::Export)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Support
|
5
|
+
module DependencyContainer
|
6
|
+
module Commands
|
7
|
+
class AssertValidMethod < Support::Command
|
8
|
+
##
|
9
|
+
# @!attribute [r] full_name
|
10
|
+
# @return [String, Symbol]
|
11
|
+
#
|
12
|
+
attr_reader :full_name
|
13
|
+
|
14
|
+
##
|
15
|
+
# @!attribute [r] scope
|
16
|
+
# @return [Symbol]
|
17
|
+
#
|
18
|
+
attr_reader :scope
|
19
|
+
|
20
|
+
##
|
21
|
+
# @!attribute [r] container
|
22
|
+
# @return [Module]
|
23
|
+
#
|
24
|
+
attr_reader :container
|
25
|
+
|
26
|
+
##
|
27
|
+
# @param full_name [String, Symbol]
|
28
|
+
# @param scope [Symbol]
|
29
|
+
# @param container[Module]
|
30
|
+
# @return [void]
|
31
|
+
#
|
32
|
+
def initialize(full_name:, scope:, container:)
|
33
|
+
@full_name = full_name
|
34
|
+
@scope = scope
|
35
|
+
@container = container
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# @return [void]
|
40
|
+
# @raise [ConvenientService::Support::DependencyContainer::Errors::NotExportedMethod]
|
41
|
+
#
|
42
|
+
def call
|
43
|
+
raise Errors::NotExportedMethod.new(method_name: full_name, method_scope: scope, mod: container) unless method
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
##
|
49
|
+
# @return [ConvenientService::Support::DependencyContainer::Entities::Method, nil]
|
50
|
+
#
|
51
|
+
def method
|
52
|
+
container.exported_methods.find_by(full_name: full_name, scope: scope)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -7,12 +7,12 @@ module ConvenientService
|
|
7
7
|
class AssertValidScope < Support::Command
|
8
8
|
##
|
9
9
|
# @!attribute [r] scope
|
10
|
-
# @return [
|
10
|
+
# @return [Symbol]
|
11
11
|
#
|
12
12
|
attr_reader :scope
|
13
13
|
|
14
14
|
##
|
15
|
-
# @param scope [
|
15
|
+
# @param scope [Symbol]
|
16
16
|
# @return [void]
|
17
17
|
#
|
18
18
|
def initialize(scope:)
|
@@ -20,7 +20,8 @@ module ConvenientService
|
|
20
20
|
end
|
21
21
|
|
22
22
|
##
|
23
|
-
# @return [
|
23
|
+
# @return [void]
|
24
|
+
# @raise [ConvenientService::Support::DependencyContainer::Errors::InvalidScope]
|
24
25
|
#
|
25
26
|
def call
|
26
27
|
raise Errors::InvalidScope.new(scope: scope) unless Constants::SCOPES.include?(scope)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Support
|
5
|
+
module DependencyContainer
|
6
|
+
module Commands
|
7
|
+
class DefineEntry < Support::Command
|
8
|
+
##
|
9
|
+
# @!attribute [r] container
|
10
|
+
# @return [Module]
|
11
|
+
#
|
12
|
+
attr_reader :container
|
13
|
+
|
14
|
+
##
|
15
|
+
# @!attribute [r] name
|
16
|
+
# @return [String, Symbol]
|
17
|
+
#
|
18
|
+
attr_reader :name
|
19
|
+
|
20
|
+
##
|
21
|
+
# @!attribute [r] body
|
22
|
+
# @return [Proc]
|
23
|
+
#
|
24
|
+
attr_reader :body
|
25
|
+
|
26
|
+
##
|
27
|
+
# @param container [Module]
|
28
|
+
# @param name [String, Symbol]
|
29
|
+
# @param body [Proc]
|
30
|
+
#
|
31
|
+
def initialize(container:, name:, body:)
|
32
|
+
@container = container
|
33
|
+
@name = name
|
34
|
+
@body = body
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# @return [String, Symbol]
|
39
|
+
#
|
40
|
+
def call
|
41
|
+
container.define_singleton_method(name, &body)
|
42
|
+
|
43
|
+
name
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "commands/assert_valid_scope"
|
4
|
+
require_relative "commands/assert_valid_container"
|
5
|
+
require_relative "commands/assert_valid_method"
|
4
6
|
require_relative "commands/create_methods_module"
|
7
|
+
require_relative "commands/define_entry"
|
5
8
|
require_relative "commands/import_method"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Support
|
5
|
+
module DependencyContainer
|
6
|
+
module Container
|
7
|
+
include Export
|
8
|
+
|
9
|
+
export :"constants.DEFAULT_SCOPE" do
|
10
|
+
Constants::DEFAULT_SCOPE
|
11
|
+
end
|
12
|
+
|
13
|
+
export :"commands.AssertValidContainer" do
|
14
|
+
Commands::AssertValidContainer
|
15
|
+
end
|
16
|
+
|
17
|
+
export :"commands.AssertValidScope" do
|
18
|
+
Commands::AssertValidScope
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Support
|
5
|
+
module DependencyContainer
|
6
|
+
module Entry
|
7
|
+
include Support::Concern
|
8
|
+
|
9
|
+
class_methods do
|
10
|
+
##
|
11
|
+
# @param name [String, Symbol]
|
12
|
+
# @param body [Proc]
|
13
|
+
# @return [String, Symbol]
|
14
|
+
#
|
15
|
+
def entry(name, &body)
|
16
|
+
Commands::DefineEntry.call(container: self, name: name, body: body)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|