convenient_service 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.dockerignore +1 -0
- data/.gem_release.yml +23 -0
- data/.github/workflows/cd.yml +54 -0
- data/.github/workflows/ci.yml +190 -0
- data/.gitignore +34 -0
- data/.inch.yml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +45 -0
- data/.rubocop_rspec.yml +58 -0
- data/.ruby-version +1 -0
- data/.tool-versions +1 -0
- data/.yardopts +13 -0
- data/Appraisals +124 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/ROADMAP.md +41 -0
- data/Rakefile +54 -0
- data/Taskfile.yml +316 -0
- data/convenient_service.gemspec +52 -0
- data/coverage/.gitkeep +0 -0
- data/docker/2.7/Dockerfile +73 -0
- data/docker/3.0/Dockerfile +73 -0
- data/docker/3.1/Dockerfile +73 -0
- data/env.rb +19 -0
- data/lib/convenient_service/common/plugins/aliases.rb +8 -0
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_active_model_attribute_assignment/concern.rb +21 -0
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_active_model_attribute_assignment/middleware.rb +29 -0
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_active_model_attribute_assignment.rb +4 -0
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_dry_initializer/concern.rb +21 -0
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_dry_initializer.rb +3 -0
- data/lib/convenient_service/common/plugins/caches_constructor_params/concern.rb +22 -0
- data/lib/convenient_service/common/plugins/caches_constructor_params/entities/constructor_params.rb +34 -0
- data/lib/convenient_service/common/plugins/caches_constructor_params/entities.rb +3 -0
- data/lib/convenient_service/common/plugins/caches_constructor_params/middleware.rb +17 -0
- data/lib/convenient_service/common/plugins/caches_constructor_params.rb +5 -0
- data/lib/convenient_service/common/plugins/caches_return_value/entities/key.rb +79 -0
- data/lib/convenient_service/common/plugins/caches_return_value/entities.rb +3 -0
- data/lib/convenient_service/common/plugins/caches_return_value/middleware.rb +17 -0
- data/lib/convenient_service/common/plugins/caches_return_value.rb +4 -0
- data/lib/convenient_service/common/plugins/can_be_copied/concern.rb +33 -0
- data/lib/convenient_service/common/plugins/can_be_copied.rb +3 -0
- data/lib/convenient_service/common/plugins/has_around_callbacks/concern.rb +19 -0
- data/lib/convenient_service/common/plugins/has_around_callbacks/errors.rb +29 -0
- data/lib/convenient_service/common/plugins/has_around_callbacks/middleware.rb +113 -0
- data/lib/convenient_service/common/plugins/has_around_callbacks.rb +5 -0
- data/lib/convenient_service/common/plugins/has_attributes/using_active_model_attributes/concern.rb +19 -0
- data/lib/convenient_service/common/plugins/has_attributes/using_active_model_attributes/patches/active_model_attributes.rb +45 -0
- data/lib/convenient_service/common/plugins/has_attributes/using_active_model_attributes/patches.rb +3 -0
- data/lib/convenient_service/common/plugins/has_attributes/using_active_model_attributes.rb +4 -0
- data/lib/convenient_service/common/plugins/has_callbacks/concern.rb +36 -0
- data/lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb +59 -0
- data/lib/convenient_service/common/plugins/has_callbacks/entities/callback_collection.rb +35 -0
- data/lib/convenient_service/common/plugins/has_callbacks/entities/type/class_methods.rb +26 -0
- data/lib/convenient_service/common/plugins/has_callbacks/entities/type.rb +50 -0
- data/lib/convenient_service/common/plugins/has_callbacks/entities/type_collection.rb +33 -0
- data/lib/convenient_service/common/plugins/has_callbacks/entities.rb +6 -0
- data/lib/convenient_service/common/plugins/has_callbacks/middleware.rb +21 -0
- data/lib/convenient_service/common/plugins/has_callbacks.rb +5 -0
- data/lib/convenient_service/common/plugins/has_constructor/concern.rb +18 -0
- data/lib/convenient_service/common/plugins/has_constructor.rb +3 -0
- data/lib/convenient_service/common/plugins/has_internals/commands/create_internals_class.rb +56 -0
- data/lib/convenient_service/common/plugins/has_internals/commands.rb +3 -0
- data/lib/convenient_service/common/plugins/has_internals/concern.rb +28 -0
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/concern.rb +25 -0
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/concern.rb +30 -0
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/entities/cache.rb +81 -0
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/entities.rb +3 -0
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache.rb +4 -0
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins.rb +3 -0
- data/lib/convenient_service/common/plugins/has_internals/entities/internals.rb +18 -0
- data/lib/convenient_service/common/plugins/has_internals/entities.rb +3 -0
- data/lib/convenient_service/common/plugins/has_internals.rb +5 -0
- data/lib/convenient_service/common/plugins/normalizes_env/middleware.rb +29 -0
- data/lib/convenient_service/common/plugins/normalizes_env.rb +3 -0
- data/lib/convenient_service/common/plugins.rb +16 -0
- data/lib/convenient_service/common.rb +3 -0
- data/lib/convenient_service/configs/aliases.rb +7 -0
- data/lib/convenient_service/configs/standard.rb +193 -0
- data/lib/convenient_service/configs.rb +5 -0
- data/lib/convenient_service/core/aliases.rb +9 -0
- data/lib/convenient_service/core/class_methods.rb +81 -0
- data/lib/convenient_service/core/entities/classic_middleware.rb +32 -0
- data/lib/convenient_service/core/entities/config/entities/concerns/entities/default_concern.rb +18 -0
- data/lib/convenient_service/core/entities/config/entities/concerns/entities/middleware/commands/cast_middleware.rb +78 -0
- data/lib/convenient_service/core/entities/config/entities/concerns/entities/middleware/commands.rb +3 -0
- data/lib/convenient_service/core/entities/config/entities/concerns/entities/middleware.rb +103 -0
- data/lib/convenient_service/core/entities/config/entities/concerns/entities/stack.rb +206 -0
- data/lib/convenient_service/core/entities/config/entities/concerns/entities.rb +5 -0
- data/lib/convenient_service/core/entities/config/entities/concerns.rb +216 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/commands/generate_stack_name.rb +95 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/commands.rb +3 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/caller/commands/cast_caller.rb +72 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/caller/commands/define_method_middlewares_caller.rb +134 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/caller/commands.rb +4 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/caller/concern/class_methods.rb +29 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/caller/concern/instance_methods.rb +66 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/caller/concern.rb +32 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/caller.rb +25 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb +71 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/commands/cast_container.rb +76 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/commands/resolve_methods_middlewares_callers.rb +72 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/commands.rb +4 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/concern/class_methods.rb +29 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/concern/instance_methods.rb +165 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/concern.rb +32 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container.rb +22 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middleware.rb +114 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/stack.rb +193 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities.rb +7 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares.rb +182 -0
- data/lib/convenient_service/core/entities/config/entities.rb +4 -0
- data/lib/convenient_service/core/entities/config/errors.rb +27 -0
- data/lib/convenient_service/core/entities/config.rb +147 -0
- data/lib/convenient_service/core/entities.rb +4 -0
- data/lib/convenient_service/core/instance_methods.rb +54 -0
- data/lib/convenient_service/core.rb +19 -0
- data/lib/convenient_service/dependencies/built_in.rb +36 -0
- data/lib/convenient_service/dependencies/extractions/active_support_concern/concern.rb +258 -0
- data/lib/convenient_service/dependencies/extractions/active_support_concern.rb +16 -0
- data/lib/convenient_service/dependencies/extractions/b.rb +12 -0
- data/lib/convenient_service/dependencies/extractions/byebug_syntax_highlighting.rb +58 -0
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/builder.rb +194 -0
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/logger.rb +60 -0
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/runner.rb +79 -0
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware.rb +8 -0
- data/lib/convenient_service/dependencies/extractions/ruby_middleware.rb +15 -0
- data/lib/convenient_service/dependencies/extractions.rb +10 -0
- data/lib/convenient_service/dependencies.rb +133 -0
- data/lib/convenient_service/error.rb +16 -0
- data/lib/convenient_service/examples/dry/gemfile/dry_service/config.rb +43 -0
- data/lib/convenient_service/examples/dry/gemfile/dry_service.rb +3 -0
- data/lib/convenient_service/examples/dry/gemfile/services/assert_file_exists.rb +29 -0
- data/lib/convenient_service/examples/dry/gemfile/services/assert_file_not_empty.rb +29 -0
- data/lib/convenient_service/examples/dry/gemfile/services/assert_node_available.rb +26 -0
- data/lib/convenient_service/examples/dry/gemfile/services/assert_npm_package_available.rb +39 -0
- data/lib/convenient_service/examples/dry/gemfile/services/assert_valid_ruby_syntax.rb +41 -0
- data/lib/convenient_service/examples/dry/gemfile/services/format.rb +37 -0
- data/lib/convenient_service/examples/dry/gemfile/services/format_body.rb +93 -0
- data/lib/convenient_service/examples/dry/gemfile/services/format_gems_with_envs.rb +96 -0
- data/lib/convenient_service/examples/dry/gemfile/services/format_gems_without_envs.rb +84 -0
- data/lib/convenient_service/examples/dry/gemfile/services/format_header.rb +74 -0
- data/lib/convenient_service/examples/dry/gemfile/services/parse_content.rb +93 -0
- data/lib/convenient_service/examples/dry/gemfile/services/print_shell_command.rb +37 -0
- data/lib/convenient_service/examples/dry/gemfile/services/read_file_content.rb +31 -0
- data/lib/convenient_service/examples/dry/gemfile/services/run_shell.rb +40 -0
- data/lib/convenient_service/examples/dry/gemfile/services/strip_comments.rb +109 -0
- data/lib/convenient_service/examples/dry/gemfile/services.rb +17 -0
- data/lib/convenient_service/examples/dry/gemfile.rb +24 -0
- data/lib/convenient_service/examples/rails/gemfile/rails_service/config.rb +54 -0
- data/lib/convenient_service/examples/rails/gemfile/rails_service.rb +3 -0
- data/lib/convenient_service/examples/rails/gemfile/services/assert_file_exists.rb +25 -0
- data/lib/convenient_service/examples/rails/gemfile/services/assert_file_not_empty.rb +25 -0
- data/lib/convenient_service/examples/rails/gemfile/services/assert_node_available.rb +26 -0
- data/lib/convenient_service/examples/rails/gemfile/services/assert_npm_package_available.rb +35 -0
- data/lib/convenient_service/examples/rails/gemfile/services/assert_valid_ruby_syntax.rb +35 -0
- data/lib/convenient_service/examples/rails/gemfile/services/format.rb +37 -0
- data/lib/convenient_service/examples/rails/gemfile/services/format_body.rb +79 -0
- data/lib/convenient_service/examples/rails/gemfile/services/format_gems_with_envs.rb +82 -0
- data/lib/convenient_service/examples/rails/gemfile/services/format_gems_without_envs.rb +70 -0
- data/lib/convenient_service/examples/rails/gemfile/services/format_header.rb +69 -0
- data/lib/convenient_service/examples/rails/gemfile/services/parse_content.rb +89 -0
- data/lib/convenient_service/examples/rails/gemfile/services/print_shell_command.rb +33 -0
- data/lib/convenient_service/examples/rails/gemfile/services/read_file_content.rb +27 -0
- data/lib/convenient_service/examples/rails/gemfile/services/run_shell.rb +35 -0
- data/lib/convenient_service/examples/rails/gemfile/services/strip_comments.rb +107 -0
- data/lib/convenient_service/examples/rails/gemfile/services.rb +17 -0
- data/lib/convenient_service/examples/rails/gemfile.rb +24 -0
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb +30 -0
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_not_empty.rb +30 -0
- data/lib/convenient_service/examples/standard/gemfile/services/assert_node_available.rb +35 -0
- data/lib/convenient_service/examples/standard/gemfile/services/assert_npm_package_available.rb +48 -0
- data/lib/convenient_service/examples/standard/gemfile/services/assert_valid_ruby_syntax.rb +39 -0
- data/lib/convenient_service/examples/standard/gemfile/services/format.rb +39 -0
- data/lib/convenient_service/examples/standard/gemfile/services/format_body.rb +83 -0
- data/lib/convenient_service/examples/standard/gemfile/services/format_gems_with_envs.rb +86 -0
- data/lib/convenient_service/examples/standard/gemfile/services/format_gems_without_envs.rb +74 -0
- data/lib/convenient_service/examples/standard/gemfile/services/format_header.rb +66 -0
- data/lib/convenient_service/examples/standard/gemfile/services/parse_content.rb +101 -0
- data/lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb +38 -0
- data/lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb +39 -0
- data/lib/convenient_service/examples/standard/gemfile/services/run_shell.rb +37 -0
- data/lib/convenient_service/examples/standard/gemfile/services/strip_comments.rb +111 -0
- data/lib/convenient_service/examples/standard/gemfile/services.rb +17 -0
- data/lib/convenient_service/examples/standard/gemfile.rb +23 -0
- data/lib/convenient_service/logger.rb +70 -0
- data/lib/convenient_service/rspec/helpers/custom/ignoring_error.rb +29 -0
- data/lib/convenient_service/rspec/helpers/custom/stub_service/entities/result_spec.rb +119 -0
- data/lib/convenient_service/rspec/helpers/custom/stub_service/entities/stubbed_service.rb +99 -0
- data/lib/convenient_service/rspec/helpers/custom/stub_service/entities.rb +4 -0
- data/lib/convenient_service/rspec/helpers/custom/stub_service.rb +26 -0
- data/lib/convenient_service/rspec/helpers/custom/wrap_method/entities/wrapped_method.rb +80 -0
- data/lib/convenient_service/rspec/helpers/custom/wrap_method/entities.rb +3 -0
- data/lib/convenient_service/rspec/helpers/custom/wrap_method/errors.rb +25 -0
- data/lib/convenient_service/rspec/helpers/custom/wrap_method.rb +27 -0
- data/lib/convenient_service/rspec/helpers/custom.rb +5 -0
- data/lib/convenient_service/rspec/helpers/ignoring_error.rb +13 -0
- data/lib/convenient_service/rspec/helpers/stub_service.rb +29 -0
- data/lib/convenient_service/rspec/helpers/wrap_method.rb +13 -0
- data/lib/convenient_service/rspec/helpers.rb +21 -0
- data/lib/convenient_service/rspec/matchers/be_descendant_of.rb +13 -0
- data/lib/convenient_service/rspec/matchers/be_direct_descendant_of.rb +13 -0
- data/lib/convenient_service/rspec/matchers/cache_its_value.rb +13 -0
- data/lib/convenient_service/rspec/matchers/call_chain_next.rb +13 -0
- data/lib/convenient_service/rspec/matchers/custom/be_descendant_of.rb +55 -0
- data/lib/convenient_service/rspec/matchers/custom/be_direct_descendant_of.rb +55 -0
- data/lib/convenient_service/rspec/matchers/custom/cache_its_value.rb +55 -0
- data/lib/convenient_service/rspec/matchers/custom/call_chain_next.rb +150 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to.rb +255 -0
- data/lib/convenient_service/rspec/matchers/custom/extend_module.rb +40 -0
- data/lib/convenient_service/rspec/matchers/custom/have_abstract_method.rb +45 -0
- data/lib/convenient_service/rspec/matchers/custom/have_alias_method.rb +45 -0
- data/lib/convenient_service/rspec/matchers/custom/have_attr_accessor.rb +43 -0
- data/lib/convenient_service/rspec/matchers/custom/have_attr_reader.rb +47 -0
- data/lib/convenient_service/rspec/matchers/custom/have_attr_writer.rb +47 -0
- data/lib/convenient_service/rspec/matchers/custom/include_module.rb +40 -0
- data/lib/convenient_service/rspec/matchers/custom/prepend_module.rb +40 -0
- data/lib/convenient_service/rspec/matchers/custom/results/be_error.rb +153 -0
- data/lib/convenient_service/rspec/matchers/custom/results/be_failure.rb +120 -0
- data/lib/convenient_service/rspec/matchers/custom/results/be_success.rb +120 -0
- data/lib/convenient_service/rspec/matchers/custom/results.rb +5 -0
- data/lib/convenient_service/rspec/matchers/custom.rb +16 -0
- data/lib/convenient_service/rspec/matchers/delegate_to.rb +13 -0
- data/lib/convenient_service/rspec/matchers/extend_module.rb +13 -0
- data/lib/convenient_service/rspec/matchers/have_abstract_method.rb +13 -0
- data/lib/convenient_service/rspec/matchers/have_alias_method.rb +13 -0
- data/lib/convenient_service/rspec/matchers/have_attr_accessor.rb +13 -0
- data/lib/convenient_service/rspec/matchers/have_attr_reader.rb +13 -0
- data/lib/convenient_service/rspec/matchers/have_attr_writer.rb +13 -0
- data/lib/convenient_service/rspec/matchers/include_module.rb +13 -0
- data/lib/convenient_service/rspec/matchers/prepend_module.rb +13 -0
- data/lib/convenient_service/rspec/matchers/results/be_error.rb +15 -0
- data/lib/convenient_service/rspec/matchers/results/be_failure.rb +15 -0
- data/lib/convenient_service/rspec/matchers/results/be_success.rb +15 -0
- data/lib/convenient_service/rspec/matchers/results.rb +21 -0
- data/lib/convenient_service/rspec/matchers.rb +43 -0
- data/lib/convenient_service/rspec.rb +4 -0
- data/lib/convenient_service/service/plugins/aliases.rb +8 -0
- data/lib/convenient_service/service/plugins/can_recalculate_result/concern.rb +26 -0
- data/lib/convenient_service/service/plugins/can_recalculate_result.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/commands/create_result_class.rb +56 -0
- data/lib/convenient_service/service/plugins/has_result/commands.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/concern/class_methods.rb +82 -0
- data/lib/convenient_service/service/plugins/has_result/concern/instance_methods.rb +32 -0
- data/lib/convenient_service/service/plugins/has_result/concern.rb +22 -0
- data/lib/convenient_service/service/plugins/has_result/constants.rb +33 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/commands/cast_result_params.rb +33 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/commands.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/concern/instance_methods.rb +64 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/concern.rb +19 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/code/class_methods.rb +30 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/code.rb +45 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/data/class_methods.rb +28 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/data.rb +45 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/message/class_methods.rb +30 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/message.rb +41 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/status/class_methods.rb +30 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/status.rb +69 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities.rb +6 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/errors.rb +25 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_recalculate_result/concern.rb +27 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_recalculate_result.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax/concern/instance_methods.rb +28 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax/concern.rb +30 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/marks_result_status_as_checked/middleware.rb +25 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/marks_result_status_as_checked.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/raises_on_not_checked_result_status/errors.rb +31 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/raises_on_not_checked_result_status/middleware.rb +33 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/raises_on_not_checked_result_status.rb +4 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins.rb +6 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/structs/result_params.rb +17 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/structs.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result.rb +22 -0
- data/lib/convenient_service/service/plugins/has_result/entities.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/errors.rb +34 -0
- data/lib/convenient_service/service/plugins/has_result/middleware.rb +19 -0
- data/lib/convenient_service/service/plugins/has_result.rb +8 -0
- data/lib/convenient_service/service/plugins/has_result_method_steps/errors.rb +23 -0
- data/lib/convenient_service/service/plugins/has_result_method_steps/middleware.rb +37 -0
- data/lib/convenient_service/service/plugins/has_result_method_steps/services/method_step_config.rb +29 -0
- data/lib/convenient_service/service/plugins/has_result_method_steps/services/run_method_in_organizer.rb +30 -0
- data/lib/convenient_service/service/plugins/has_result_method_steps/services/run_own_method_in_organizer.rb +52 -0
- data/lib/convenient_service/service/plugins/has_result_method_steps/services.rb +5 -0
- data/lib/convenient_service/service/plugins/has_result_method_steps.rb +5 -0
- data/lib/convenient_service/service/plugins/has_result_params_validations/using_active_model_validations/concern.rb +19 -0
- data/lib/convenient_service/service/plugins/has_result_params_validations/using_active_model_validations/middleware.rb +35 -0
- data/lib/convenient_service/service/plugins/has_result_params_validations/using_active_model_validations.rb +4 -0
- data/lib/convenient_service/service/plugins/has_result_params_validations/using_dry_validation/concern.rb +22 -0
- data/lib/convenient_service/service/plugins/has_result_params_validations/using_dry_validation/middleware.rb +39 -0
- data/lib/convenient_service/service/plugins/has_result_params_validations/using_dry_validation.rb +4 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/concern.rb +30 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/error/commands/assert_args_count_lower_than_three.rb +25 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/error/commands/assert_either_args_or_kwargs_are_passed.rb +26 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/error/commands.rb +4 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/error/errors.rb +46 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/error/middleware.rb +27 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/error.rb +5 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/failure/commands/refute_kwargs_contain_data_and_extra_keys.rb +29 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/failure/commands.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/failure/errors.rb +28 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/failure/middleware.rb +19 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/failure.rb +5 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/success/commands/refute_kwargs_contain_data_and_extra_keys.rb +29 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/success/commands.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/success/errors.rb +28 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/success/middleware.rb +19 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax/success.rb +5 -0
- data/lib/convenient_service/service/plugins/has_result_short_syntax.rb +6 -0
- data/lib/convenient_service/service/plugins/has_result_steps/commands/create_step_class.rb +60 -0
- data/lib/convenient_service/service/plugins/has_result_steps/commands.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_steps/concern.rb +53 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method.rb +54 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_caller.rb +67 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_direction.rb +65 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_key.rb +71 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_name.rb +74 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/define_method_in_container.rb +55 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands.rb +8 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/concern/class_methods.rb +21 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/concern/instance_methods.rb +96 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/concern.rb +29 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers/alias.rb +39 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers/base.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers/proc.rb +42 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers/raw.rb +42 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers/usual.rb +39 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers.rb +7 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/directions/base.rb +33 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/directions/input.rb +31 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/directions/output.rb +31 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/directions.rb +5 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/key.rb +40 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/name.rb +40 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/values/raw.rb +48 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/values.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities.rb +7 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/errors.rb +127 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method.rb +20 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/service/class_methods.rb +32 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/service.rb +48 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/commands/cast_params.rb +61 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/commands/extract_params.rb +38 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/commands.rb +4 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/concern/instance_methods.rb +138 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/concern.rb +23 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/errors.rb +23 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/structs/params.rb +17 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/structs.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step.rb +20 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb +61 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities.rb +6 -0
- data/lib/convenient_service/service/plugins/has_result_steps/middleware.rb +26 -0
- data/lib/convenient_service/service/plugins/has_result_steps.rb +6 -0
- data/lib/convenient_service/service/plugins/raises_on_double_result/errors.rb +34 -0
- data/lib/convenient_service/service/plugins/raises_on_double_result/middleware.rb +33 -0
- data/lib/convenient_service/service/plugins/raises_on_double_result.rb +4 -0
- data/lib/convenient_service/service/plugins/wraps_result_in_db_transaction/middleware.rb +15 -0
- data/lib/convenient_service/service/plugins/wraps_result_in_db_transaction.rb +3 -0
- data/lib/convenient_service/service/plugins.rb +14 -0
- data/lib/convenient_service/service.rb +3 -0
- data/lib/convenient_service/specification.rb +21 -0
- data/lib/convenient_service/support/abstract_method/errors.rb +22 -0
- data/lib/convenient_service/support/abstract_method.rb +21 -0
- data/lib/convenient_service/support/castable/errors.rb +29 -0
- data/lib/convenient_service/support/castable.rb +44 -0
- data/lib/convenient_service/support/command.rb +25 -0
- data/lib/convenient_service/support/concern.rb +11 -0
- data/lib/convenient_service/support/copyable.rb +56 -0
- data/lib/convenient_service/support/delegate.rb +42 -0
- data/lib/convenient_service/support/finite_loop.rb +49 -0
- data/lib/convenient_service/support/middleware/stack_builder.rb +78 -0
- data/lib/convenient_service/support/middleware.rb +3 -0
- data/lib/convenient_service/support.rb +11 -0
- data/lib/convenient_service/utils/array/contain_exactly.rb +56 -0
- data/lib/convenient_service/utils/array/drop_while.rb +50 -0
- data/lib/convenient_service/utils/array/errors.rb +19 -0
- data/lib/convenient_service/utils/array/find_last.rb +38 -0
- data/lib/convenient_service/utils/array/find_yield.rb +93 -0
- data/lib/convenient_service/utils/array/keep_after.rb +41 -0
- data/lib/convenient_service/utils/array/merge.rb +77 -0
- data/lib/convenient_service/utils/array/rjust.rb +50 -0
- data/lib/convenient_service/utils/array/wrap.rb +40 -0
- data/lib/convenient_service/utils/array.rb +52 -0
- data/lib/convenient_service/utils/bool/to_bool.rb +37 -0
- data/lib/convenient_service/utils/bool.rb +15 -0
- data/lib/convenient_service/utils/hash/except.rb +46 -0
- data/lib/convenient_service/utils/hash.rb +15 -0
- data/lib/convenient_service/utils/method/defined.rb +49 -0
- data/lib/convenient_service/utils/method.rb +15 -0
- data/lib/convenient_service/utils/module/class_method_defined.rb +46 -0
- data/lib/convenient_service/utils/module/get_own_const.rb +60 -0
- data/lib/convenient_service/utils/module/get_own_instance_method.rb +81 -0
- data/lib/convenient_service/utils/module/has_own_instance_method.rb +77 -0
- data/lib/convenient_service/utils/module/instance_method_defined.rb +46 -0
- data/lib/convenient_service/utils/module.rb +40 -0
- data/lib/convenient_service/utils/object/resolve_type.rb +47 -0
- data/lib/convenient_service/utils/object.rb +19 -0
- data/lib/convenient_service/utils/proc/conjunct.rb +48 -0
- data/lib/convenient_service/utils/proc/exec_config.rb +136 -0
- data/lib/convenient_service/utils/proc.rb +20 -0
- data/lib/convenient_service/utils/string/camelize.rb +56 -0
- data/lib/convenient_service/utils/string.rb +15 -0
- data/lib/convenient_service/utils.rb +10 -0
- data/lib/convenient_service/version.rb +5 -0
- data/lib/convenient_service.rb +31 -0
- data/logo.png +0 -0
- metadata +738 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module CanRecalculateResult
|
7
|
+
module Concern
|
8
|
+
include Support::Concern
|
9
|
+
|
10
|
+
##
|
11
|
+
# NOTE: `CanRecalculateResult` plugin expects that `CanBeCopied` plugin is already included.
|
12
|
+
# That is why `copy` method is available.
|
13
|
+
#
|
14
|
+
# NOTE: `CanRecalculateResult` plugin expects that `HasResult` plugin is already included.
|
15
|
+
# That is why `result` method is available.
|
16
|
+
#
|
17
|
+
instance_methods do
|
18
|
+
def recalculate_result
|
19
|
+
copy.result
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module HasResult
|
7
|
+
module Commands
|
8
|
+
class CreateResultClass < Support::Command
|
9
|
+
attr_reader :service_class
|
10
|
+
|
11
|
+
def initialize(service_class:)
|
12
|
+
@service_class = service_class
|
13
|
+
end
|
14
|
+
|
15
|
+
def call
|
16
|
+
result_class.include Entities::Result::Concern
|
17
|
+
|
18
|
+
##
|
19
|
+
# class Result < ConvenientService::Service::Plugins::HasResult::Entities::Result # or just `class Result` if service class defines its own.
|
20
|
+
# include ConvenientService::Service::Plugins::HasResult::Entities::Result::Concern
|
21
|
+
#
|
22
|
+
# class << self
|
23
|
+
# def service_class
|
24
|
+
# ##
|
25
|
+
# # NOTE: Returns `service_class` passed to `CreateResultClass`.
|
26
|
+
# #
|
27
|
+
# service_class
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# def ==(other)
|
31
|
+
# return unless other.instance_of?(self.class)
|
32
|
+
#
|
33
|
+
# self.service_class == other.service_class
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
result_class.class_exec(service_class) do |service_class|
|
39
|
+
define_singleton_method(:service_class) { service_class }
|
40
|
+
define_singleton_method(:==) { |other| self.service_class == other.service_class if other.instance_of?(self.class) }
|
41
|
+
end
|
42
|
+
|
43
|
+
result_class
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def result_class
|
49
|
+
@result_class ||= Utils::Module.get_own_const(service_class, :Result) || ::Class.new(Entities::Result)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module HasResult
|
7
|
+
module Concern
|
8
|
+
module ClassMethods
|
9
|
+
##
|
10
|
+
#
|
11
|
+
#
|
12
|
+
def result(...)
|
13
|
+
new(...).result
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# https://ruby-doc.org/core-2.5.0/Class.html#method-i-allocate
|
18
|
+
# https://frontdeveloper.pl/2018/11/ruby-allocate-method/
|
19
|
+
#
|
20
|
+
def new_without_initialize
|
21
|
+
allocate
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# NOTE: This method is internally used by custom RSpec helper `stub_service`. It should NOT be used in the client code.
|
26
|
+
#
|
27
|
+
def success(
|
28
|
+
service: Constants::DEFAULT_SERVICE_INSTANCE,
|
29
|
+
data: Constants::DEFAULT_SUCCESS_DATA
|
30
|
+
)
|
31
|
+
result_class.new(
|
32
|
+
service: service,
|
33
|
+
status: Constants::SUCCESS_STATUS,
|
34
|
+
data: data,
|
35
|
+
message: Constants::SUCCESS_MESSAGE,
|
36
|
+
code: Constants::SUCCESS_CODE
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# NOTE: This method is internally used by custom RSpec helper `stub_service`. It should NOT be used in the client code.
|
42
|
+
#
|
43
|
+
def failure(
|
44
|
+
service: Constants::DEFAULT_SERVICE_INSTANCE,
|
45
|
+
data: Constants::DEFAULT_FAILURE_DATA,
|
46
|
+
message: data.any? ? data.first.join(" ") : Constants::DEFAULT_FAILURE_MESSAGE
|
47
|
+
)
|
48
|
+
result_class.new(
|
49
|
+
service: service,
|
50
|
+
status: Constants::FAILURE_STATUS,
|
51
|
+
data: data,
|
52
|
+
message: message,
|
53
|
+
code: Constants::FAILURE_CODE
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# NOTE: This method is internally used by custom RSpec helper `stub_service`. It should NOT be used in the client code.
|
59
|
+
#
|
60
|
+
def error(
|
61
|
+
service: Constants::DEFAULT_SERVICE_INSTANCE,
|
62
|
+
message: Constants::DEFAULT_ERROR_MESSAGE,
|
63
|
+
code: Constants::DEFAULT_ERROR_CODE
|
64
|
+
)
|
65
|
+
result_class.new(
|
66
|
+
service: service,
|
67
|
+
status: Constants::ERROR_STATUS,
|
68
|
+
data: Constants::ERROR_DATA,
|
69
|
+
message: message,
|
70
|
+
code: code
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
def result_class
|
75
|
+
@result_class ||= Commands::CreateResultClass.call(service_class: self)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module HasResult
|
7
|
+
module Concern
|
8
|
+
module InstanceMethods
|
9
|
+
def result
|
10
|
+
raise Errors::ResultIsNotOverridden.new(service: self)
|
11
|
+
end
|
12
|
+
|
13
|
+
##
|
14
|
+
# TODO: Specs.
|
15
|
+
#
|
16
|
+
def success(**kwargs)
|
17
|
+
self.class.success(**kwargs.merge(service: self))
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure(**kwargs)
|
21
|
+
self.class.failure(**kwargs.merge(service: self))
|
22
|
+
end
|
23
|
+
|
24
|
+
def error(**kwargs)
|
25
|
+
self.class.error(**kwargs.merge(service: self))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "concern/instance_methods"
|
4
|
+
require_relative "concern/class_methods"
|
5
|
+
|
6
|
+
module ConvenientService
|
7
|
+
module Service
|
8
|
+
module Plugins
|
9
|
+
module HasResult
|
10
|
+
module Concern
|
11
|
+
include Support::Concern
|
12
|
+
|
13
|
+
included do |service_class|
|
14
|
+
service_class.include InstanceMethods
|
15
|
+
|
16
|
+
service_class.extend ClassMethods
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module HasResult
|
7
|
+
module Constants
|
8
|
+
##
|
9
|
+
# TODO: Consider to include `::ConvenientService::Configs::Minimal`
|
10
|
+
#
|
11
|
+
DEFAULT_SERVICE_CLASS = ::Class.new { include ::ConvenientService::Core }
|
12
|
+
DEFAULT_SERVICE_INSTANCE = DEFAULT_SERVICE_CLASS.new
|
13
|
+
|
14
|
+
SUCCESS_STATUS = :success
|
15
|
+
FAILURE_STATUS = :failure
|
16
|
+
ERROR_STATUS = :error
|
17
|
+
|
18
|
+
DEFAULT_SUCCESS_DATA = {}
|
19
|
+
DEFAULT_FAILURE_DATA = {}
|
20
|
+
ERROR_DATA = {}
|
21
|
+
|
22
|
+
SUCCESS_MESSAGE = ""
|
23
|
+
DEFAULT_FAILURE_MESSAGE = ""
|
24
|
+
DEFAULT_ERROR_MESSAGE = ""
|
25
|
+
|
26
|
+
SUCCESS_CODE = :success
|
27
|
+
FAILURE_CODE = :failure
|
28
|
+
DEFAULT_ERROR_CODE = :default_error
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module HasResult
|
7
|
+
module Entities
|
8
|
+
class Result
|
9
|
+
module Commands
|
10
|
+
class CastResultParams < Support::Command
|
11
|
+
attr_reader :params
|
12
|
+
|
13
|
+
def initialize(params:)
|
14
|
+
@params = params
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
Structs::ResultParams.new(
|
19
|
+
service: params[:service],
|
20
|
+
status: Entities::Status.cast!(params[:status]),
|
21
|
+
data: Entities::Data.cast!(params[:data]),
|
22
|
+
message: Entities::Message.cast!(params[:message]),
|
23
|
+
code: Entities::Code.cast!(params[:code])
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/convenient_service/service/plugins/has_result/entities/result/concern/instance_methods.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module HasResult
|
7
|
+
module Entities
|
8
|
+
class Result
|
9
|
+
module Concern
|
10
|
+
##
|
11
|
+
# TODO: How to use concern outside?
|
12
|
+
#
|
13
|
+
module InstanceMethods
|
14
|
+
include Support::Delegate
|
15
|
+
include Support::Copyable
|
16
|
+
|
17
|
+
delegate \
|
18
|
+
:service,
|
19
|
+
:status,
|
20
|
+
:data,
|
21
|
+
:message,
|
22
|
+
:code,
|
23
|
+
to: :params
|
24
|
+
|
25
|
+
delegate \
|
26
|
+
:success?,
|
27
|
+
:failure?,
|
28
|
+
:error?,
|
29
|
+
:not_success?,
|
30
|
+
:not_failure?,
|
31
|
+
:not_error?,
|
32
|
+
to: :status
|
33
|
+
|
34
|
+
def initialize(**params)
|
35
|
+
@params = Commands::CastResultParams.call(params: params)
|
36
|
+
end
|
37
|
+
|
38
|
+
def ==(other)
|
39
|
+
return unless other.instance_of?(self.class)
|
40
|
+
|
41
|
+
return false if service.class != other.service.class
|
42
|
+
return false if status != other.status
|
43
|
+
return false if data != other.data
|
44
|
+
return false if message != other.message
|
45
|
+
return false if code != other.code
|
46
|
+
|
47
|
+
true
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_kwargs
|
51
|
+
{service: service, status: status, data: data, message: message, code: code}
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
attr_reader :params
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "concern/instance_methods"
|
4
|
+
|
5
|
+
module ConvenientService
|
6
|
+
module Service
|
7
|
+
module Plugins
|
8
|
+
module HasResult
|
9
|
+
module Entities
|
10
|
+
class Result
|
11
|
+
module Concern
|
12
|
+
include Support::Concern
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module HasResult
|
7
|
+
module Entities
|
8
|
+
class Result
|
9
|
+
module Entities
|
10
|
+
class Code
|
11
|
+
module ClassMethods
|
12
|
+
def cast(other)
|
13
|
+
case other
|
14
|
+
when ::String
|
15
|
+
new(value: other.to_sym)
|
16
|
+
when ::Symbol
|
17
|
+
new(value: other)
|
18
|
+
when Code
|
19
|
+
new(value: other.value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "code/class_methods"
|
4
|
+
|
5
|
+
module ConvenientService
|
6
|
+
module Service
|
7
|
+
module Plugins
|
8
|
+
module HasResult
|
9
|
+
module Entities
|
10
|
+
class Result
|
11
|
+
module Entities
|
12
|
+
class Code
|
13
|
+
include Support::Castable
|
14
|
+
|
15
|
+
extend ClassMethods
|
16
|
+
|
17
|
+
attr_reader :value
|
18
|
+
|
19
|
+
def initialize(value:)
|
20
|
+
@value = value
|
21
|
+
end
|
22
|
+
|
23
|
+
def ==(other)
|
24
|
+
casted = cast(other)
|
25
|
+
|
26
|
+
return unless casted
|
27
|
+
|
28
|
+
value == casted.value
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
@to_s ||= value.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_sym
|
36
|
+
@to_sym ||= value.to_sym
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module HasResult
|
7
|
+
module Entities
|
8
|
+
class Result
|
9
|
+
module Entities
|
10
|
+
class Data
|
11
|
+
module ClassMethods
|
12
|
+
def cast(other)
|
13
|
+
case other
|
14
|
+
when ::Hash
|
15
|
+
new(value: other.transform_keys(&:to_sym))
|
16
|
+
when Data
|
17
|
+
new(value: other.value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "data/class_methods"
|
4
|
+
|
5
|
+
module ConvenientService
|
6
|
+
module Service
|
7
|
+
module Plugins
|
8
|
+
module HasResult
|
9
|
+
module Entities
|
10
|
+
class Result
|
11
|
+
module Entities
|
12
|
+
class Data
|
13
|
+
include Support::Castable
|
14
|
+
|
15
|
+
extend ClassMethods
|
16
|
+
|
17
|
+
attr_reader :value
|
18
|
+
|
19
|
+
def initialize(value:)
|
20
|
+
@value = value
|
21
|
+
end
|
22
|
+
|
23
|
+
def ==(other)
|
24
|
+
casted = cast(other)
|
25
|
+
|
26
|
+
return unless casted
|
27
|
+
|
28
|
+
value == casted.value
|
29
|
+
end
|
30
|
+
|
31
|
+
def [](key)
|
32
|
+
value.fetch(key.to_sym) { raise Errors::NotExistingAttribute.new(attribute: key) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_h
|
36
|
+
@to_h ||= value.to_h
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module HasResult
|
7
|
+
module Entities
|
8
|
+
class Result
|
9
|
+
module Entities
|
10
|
+
class Message
|
11
|
+
module ClassMethods
|
12
|
+
def cast(other)
|
13
|
+
case other
|
14
|
+
when ::String
|
15
|
+
new(value: other)
|
16
|
+
when ::Symbol
|
17
|
+
new(value: other.to_s)
|
18
|
+
when Message
|
19
|
+
new(value: other.value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "message/class_methods"
|
4
|
+
|
5
|
+
module ConvenientService
|
6
|
+
module Service
|
7
|
+
module Plugins
|
8
|
+
module HasResult
|
9
|
+
module Entities
|
10
|
+
class Result
|
11
|
+
module Entities
|
12
|
+
class Message
|
13
|
+
include Support::Castable
|
14
|
+
|
15
|
+
extend ClassMethods
|
16
|
+
|
17
|
+
attr_reader :value
|
18
|
+
|
19
|
+
def initialize(value:)
|
20
|
+
@value = value
|
21
|
+
end
|
22
|
+
|
23
|
+
def ==(other)
|
24
|
+
casted = cast(other)
|
25
|
+
|
26
|
+
return unless casted
|
27
|
+
|
28
|
+
value == casted.value
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
@to_s ||= value.to_s
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Service
|
5
|
+
module Plugins
|
6
|
+
module HasResult
|
7
|
+
module Entities
|
8
|
+
class Result
|
9
|
+
module Entities
|
10
|
+
class Status
|
11
|
+
module ClassMethods
|
12
|
+
def cast(other)
|
13
|
+
case other
|
14
|
+
when ::String
|
15
|
+
new(value: other.to_sym)
|
16
|
+
when ::Symbol
|
17
|
+
new(value: other)
|
18
|
+
when Status
|
19
|
+
new(value: other.value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|