convenient_service 0.11.0 → 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 +67 -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 +19 -10
- 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/services/assert_npm_package_available.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile/services/format.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile/services/parse_content.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile/services/replace_file_content.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile.rb +4 -4
- data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_body.rb +0 -10
- data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path.rb +0 -10
- data/lib/convenient_service/examples/standard/request_params/services/validate_casted_params.rb +0 -10
- data/lib/convenient_service/examples/standard/request_params/services/validate_uncasted_params.rb +0 -10
- 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/export.rb +82 -0
- 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/can_have_method_steps/middleware.rb +2 -2
- data/lib/convenient_service/service/plugins/can_have_result_step/middleware.rb +2 -2
- data/lib/convenient_service/service/plugins/can_have_steps/concern.rb +2 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method.rb +46 -11
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_direction.rb +29 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_factory.rb +113 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands.rb +1 -3
- 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/can_have_steps/entities/method/entities.rb +1 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/errors.rb +7 -7
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/errors.rb +12 -8
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/aliases.rb +7 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +2 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb +37 -8
- 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/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 +75 -34
- 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 -229
- data/lib/convenient_service/factories/step/instance.rb +0 -42
- 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/can_have_steps/entities/method/commands/cast_method_caller.rb +0 -74
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_key.rb +0 -78
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_name.rb +0 -78
- 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/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities.rb +0 -0
@@ -7,7 +7,7 @@ module ConvenientService
|
|
7
7
|
module Entities
|
8
8
|
class Result
|
9
9
|
module Plugins
|
10
|
-
module
|
10
|
+
module HasJSendStatusAndAttributes
|
11
11
|
module Concern
|
12
12
|
##
|
13
13
|
# TODO: How to use concern outside?
|
@@ -52,42 +52,42 @@ module ConvenientService
|
|
52
52
|
delegate :service, to: :jsend_attributes
|
53
53
|
|
54
54
|
##
|
55
|
-
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::
|
55
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status]
|
56
56
|
#
|
57
57
|
delegate :status, to: :jsend_attributes
|
58
58
|
|
59
59
|
##
|
60
|
-
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::
|
60
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data]
|
61
61
|
#
|
62
62
|
delegate :data, to: :jsend_attributes
|
63
63
|
|
64
64
|
##
|
65
|
-
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::
|
65
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data]
|
66
66
|
#
|
67
67
|
alias_method :unsafe_data, :data
|
68
68
|
|
69
69
|
##
|
70
|
-
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::
|
70
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message]
|
71
71
|
#
|
72
72
|
delegate :message, to: :jsend_attributes
|
73
73
|
|
74
74
|
##
|
75
|
-
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::
|
75
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message]
|
76
76
|
#
|
77
77
|
alias_method :unsafe_message, :message
|
78
78
|
|
79
79
|
##
|
80
|
-
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::
|
80
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code]
|
81
81
|
#
|
82
82
|
delegate :code, to: :jsend_attributes
|
83
83
|
|
84
84
|
##
|
85
|
-
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::
|
85
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code]
|
86
86
|
#
|
87
87
|
alias_method :unsafe_code, :code
|
88
88
|
|
89
89
|
##
|
90
|
-
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::
|
90
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Structs::JSendAttributes]
|
91
91
|
#
|
92
92
|
def jsend_attributes
|
93
93
|
internals.cache[:jsend_attributes]
|
@@ -7,14 +7,14 @@ module ConvenientService
|
|
7
7
|
module Entities
|
8
8
|
class Result
|
9
9
|
module Plugins
|
10
|
-
module
|
10
|
+
module HasJSendStatusAndAttributes
|
11
11
|
module Entities
|
12
12
|
class Code
|
13
13
|
module Concern
|
14
14
|
module ClassMethods
|
15
15
|
##
|
16
16
|
# @param other [Object] Can be any type.
|
17
|
-
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::
|
17
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code, nil]
|
18
18
|
#
|
19
19
|
def cast(other)
|
20
20
|
case other
|
@@ -7,13 +7,13 @@ module ConvenientService
|
|
7
7
|
module Entities
|
8
8
|
class Result
|
9
9
|
module Plugins
|
10
|
-
module
|
10
|
+
module HasJSendStatusAndAttributes
|
11
11
|
module Entities
|
12
12
|
class Code
|
13
13
|
module Concern
|
14
14
|
module InstanceMethods
|
15
15
|
##
|
16
|
-
# @!attribute
|
16
|
+
# @!attribute [r] value
|
17
17
|
# @return [Symbol]
|
18
18
|
#
|
19
19
|
attr_reader :value
|
@@ -28,7 +28,7 @@ module ConvenientService
|
|
28
28
|
|
29
29
|
##
|
30
30
|
# @param other [Object] Can be any type.
|
31
|
-
# @return [Boolean]
|
31
|
+
# @return [Boolean, nil]
|
32
32
|
#
|
33
33
|
def ==(other)
|
34
34
|
casted = cast(other)
|
@@ -0,0 +1,38 @@
|
|
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 Plugins
|
10
|
+
module HasJSendStatusAndAttributes
|
11
|
+
module Entities
|
12
|
+
class Data
|
13
|
+
module Concern
|
14
|
+
module ClassMethods
|
15
|
+
##
|
16
|
+
# @param other [Object] Can be any type.
|
17
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data, nil]
|
18
|
+
#
|
19
|
+
def cast(other)
|
20
|
+
case other
|
21
|
+
when ::Hash
|
22
|
+
new(value: other.transform_keys(&:to_sym))
|
23
|
+
when Data
|
24
|
+
new(value: other.value)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,94 @@
|
|
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 Plugins
|
10
|
+
module HasJSendStatusAndAttributes
|
11
|
+
module Entities
|
12
|
+
class Data
|
13
|
+
module Concern
|
14
|
+
module InstanceMethods
|
15
|
+
##
|
16
|
+
# @!attribute [r] value
|
17
|
+
# @return [Hash]
|
18
|
+
#
|
19
|
+
attr_reader :value
|
20
|
+
|
21
|
+
##
|
22
|
+
# @param value [Hash]
|
23
|
+
# @return [void]
|
24
|
+
#
|
25
|
+
# @internal
|
26
|
+
# NOTE: Ruby hashes enumerate their values in the order that the corresponding keys were inserted.
|
27
|
+
# That is why the end-user can be 100% sure that the failure message is always generated from the first key/value pair.
|
28
|
+
# - https://ruby-doc.org/core-2.7.0/Hash.html
|
29
|
+
#
|
30
|
+
# TODO: A test that crashes when such behaviour is broken.
|
31
|
+
#
|
32
|
+
# NOTE: As a result, there is NO need to use any custom `OrderedHash` implementations.
|
33
|
+
# - https://api.rubyonrails.org/v5.1/classes/ActiveSupport/OrderedHash.html
|
34
|
+
# - https://github.com/rails/rails/issues/22681
|
35
|
+
# - https://api.rubyonrails.org/classes/ActiveSupport/OrderedOptions.html
|
36
|
+
#
|
37
|
+
def initialize(value:)
|
38
|
+
@value = value
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# @param key [String, Symbol]
|
43
|
+
# @return [Boolean]
|
44
|
+
#
|
45
|
+
def has_attribute?(key)
|
46
|
+
value.has_key?(key.to_sym)
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# @param other [Object] Can be any type.
|
51
|
+
# @return [Boolean, nil]
|
52
|
+
#
|
53
|
+
def ==(other)
|
54
|
+
casted = cast(other)
|
55
|
+
|
56
|
+
return unless casted
|
57
|
+
|
58
|
+
value == casted.value
|
59
|
+
end
|
60
|
+
|
61
|
+
##
|
62
|
+
# @param key [String, Symbol]
|
63
|
+
# @return [Object] Can be any type.
|
64
|
+
# @raise [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Errors::NotExistingAttribute]
|
65
|
+
#
|
66
|
+
def [](key)
|
67
|
+
value.fetch(key.to_sym) { raise Errors::NotExistingAttribute.new(attribute: key) }
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# @return [Hash]
|
72
|
+
#
|
73
|
+
def to_h
|
74
|
+
@to_h ||= value.to_h
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# @return [String]
|
79
|
+
#
|
80
|
+
def to_s
|
81
|
+
@to_s ||= to_h.to_s
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "concern/class_methods"
|
4
|
+
require_relative "concern/instance_methods"
|
5
|
+
|
6
|
+
module ConvenientService
|
7
|
+
module Service
|
8
|
+
module Plugins
|
9
|
+
module HasResult
|
10
|
+
module Entities
|
11
|
+
class Result
|
12
|
+
module Plugins
|
13
|
+
module HasJSendStatusAndAttributes
|
14
|
+
module Entities
|
15
|
+
class Data
|
16
|
+
module Concern
|
17
|
+
include Support::Concern
|
18
|
+
|
19
|
+
included do |code_class|
|
20
|
+
code_class.include Support::Castable
|
21
|
+
|
22
|
+
code_class.include InstanceMethods
|
23
|
+
|
24
|
+
code_class.extend ClassMethods
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "data/concern"
|
4
|
+
|
5
|
+
module ConvenientService
|
6
|
+
module Service
|
7
|
+
module Plugins
|
8
|
+
module HasResult
|
9
|
+
module Entities
|
10
|
+
class Result
|
11
|
+
module Plugins
|
12
|
+
module HasJSendStatusAndAttributes
|
13
|
+
module Entities
|
14
|
+
class Data
|
15
|
+
include Concern
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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 Plugins
|
10
|
+
module HasJSendStatusAndAttributes
|
11
|
+
module Entities
|
12
|
+
class Message
|
13
|
+
module Concern
|
14
|
+
module ClassMethods
|
15
|
+
##
|
16
|
+
# @param other [Object] Can be any type.
|
17
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message, nil]
|
18
|
+
#
|
19
|
+
def cast(other)
|
20
|
+
case other
|
21
|
+
when ::String
|
22
|
+
new(value: other)
|
23
|
+
when ::Symbol
|
24
|
+
new(value: other.to_s)
|
25
|
+
when Message
|
26
|
+
new(value: other.value)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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 Plugins
|
10
|
+
module HasJSendStatusAndAttributes
|
11
|
+
module Entities
|
12
|
+
class Message
|
13
|
+
module Concern
|
14
|
+
module InstanceMethods
|
15
|
+
##
|
16
|
+
# @!attribute [r] value
|
17
|
+
# @return [String]
|
18
|
+
#
|
19
|
+
attr_reader :value
|
20
|
+
|
21
|
+
##
|
22
|
+
# @param value [String]
|
23
|
+
# @return [void]
|
24
|
+
#
|
25
|
+
def initialize(value:)
|
26
|
+
@value = value
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# @param other [Object] Can be any type.
|
31
|
+
# @return [Boolean, nil]
|
32
|
+
#
|
33
|
+
def ==(other)
|
34
|
+
casted = cast(other)
|
35
|
+
|
36
|
+
return unless casted
|
37
|
+
|
38
|
+
value == casted.value
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# @return [String]
|
43
|
+
#
|
44
|
+
def to_s
|
45
|
+
@to_s ||= value.to_s
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "concern/class_methods"
|
4
|
+
require_relative "concern/instance_methods"
|
5
|
+
|
6
|
+
module ConvenientService
|
7
|
+
module Service
|
8
|
+
module Plugins
|
9
|
+
module HasResult
|
10
|
+
module Entities
|
11
|
+
class Result
|
12
|
+
module Plugins
|
13
|
+
module HasJSendStatusAndAttributes
|
14
|
+
module Entities
|
15
|
+
class Message
|
16
|
+
module Concern
|
17
|
+
include Support::Concern
|
18
|
+
|
19
|
+
included do |code_class|
|
20
|
+
code_class.include Support::Castable
|
21
|
+
|
22
|
+
code_class.include InstanceMethods
|
23
|
+
|
24
|
+
code_class.extend ClassMethods
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "message/concern"
|
4
|
+
|
5
|
+
module ConvenientService
|
6
|
+
module Service
|
7
|
+
module Plugins
|
8
|
+
module HasResult
|
9
|
+
module Entities
|
10
|
+
class Result
|
11
|
+
module Plugins
|
12
|
+
module HasJSendStatusAndAttributes
|
13
|
+
module Entities
|
14
|
+
class Message
|
15
|
+
include Concern
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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 Plugins
|
10
|
+
module HasJSendStatusAndAttributes
|
11
|
+
module Entities
|
12
|
+
class Status
|
13
|
+
module Concern
|
14
|
+
module ClassMethods
|
15
|
+
##
|
16
|
+
# @param other [Object] Can be any type.
|
17
|
+
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status, nil]
|
18
|
+
#
|
19
|
+
def cast(other)
|
20
|
+
case other
|
21
|
+
when ::String
|
22
|
+
new(value: other.to_sym)
|
23
|
+
when ::Symbol
|
24
|
+
new(value: other)
|
25
|
+
when Status
|
26
|
+
new(value: other.value)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,115 @@
|
|
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 Plugins
|
10
|
+
module HasJSendStatusAndAttributes
|
11
|
+
module Entities
|
12
|
+
class Status
|
13
|
+
module Concern
|
14
|
+
module InstanceMethods
|
15
|
+
##
|
16
|
+
# @!attribute [r] value
|
17
|
+
# @return [String]
|
18
|
+
#
|
19
|
+
attr_reader :value
|
20
|
+
|
21
|
+
##
|
22
|
+
# @param value [String]
|
23
|
+
# @return [void]
|
24
|
+
#
|
25
|
+
def initialize(value:)
|
26
|
+
@value = value
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# @param other [Object] Can be any type.
|
31
|
+
# @return [Boolean, nil]
|
32
|
+
#
|
33
|
+
def ==(other)
|
34
|
+
casted = cast(other)
|
35
|
+
|
36
|
+
return unless casted
|
37
|
+
|
38
|
+
value == casted.value
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# @return [Boolean]
|
43
|
+
#
|
44
|
+
def success?
|
45
|
+
value == :success
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# @return [Boolean]
|
50
|
+
#
|
51
|
+
def failure?
|
52
|
+
value == :failure
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# @return [Boolean]
|
57
|
+
#
|
58
|
+
def error?
|
59
|
+
value == :error
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# @return [Boolean]
|
64
|
+
#
|
65
|
+
def not_success?
|
66
|
+
!success?
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# @return [Boolean]
|
71
|
+
#
|
72
|
+
def not_failure?
|
73
|
+
!failure?
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# @return [Boolean]
|
78
|
+
#
|
79
|
+
def not_error?
|
80
|
+
!error?
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# @param statuses [Array<Symbol, String, ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status>]
|
85
|
+
# @return [Boolean]
|
86
|
+
#
|
87
|
+
def in?(statuses)
|
88
|
+
statuses.any? { |status| self == status }
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# @return [String]
|
93
|
+
#
|
94
|
+
def to_s
|
95
|
+
@to_s ||= value.to_s
|
96
|
+
end
|
97
|
+
|
98
|
+
##
|
99
|
+
# @return [Symbol]
|
100
|
+
#
|
101
|
+
def to_sym
|
102
|
+
@to_sym ||= value.to_sym
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|