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
@@ -1,32 +0,0 @@
|
|
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 ClassMethods
|
14
|
-
def cast(other)
|
15
|
-
case other
|
16
|
-
when ::Hash
|
17
|
-
new(value: other.transform_keys(&:to_sym))
|
18
|
-
when Data
|
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
|
31
|
-
end
|
32
|
-
end
|
@@ -1,74 +0,0 @@
|
|
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 Plugins
|
12
|
-
module HasJsendStatusAndAttributes
|
13
|
-
module Entities
|
14
|
-
class Data
|
15
|
-
include Support::Castable
|
16
|
-
|
17
|
-
extend ClassMethods
|
18
|
-
|
19
|
-
attr_reader :value
|
20
|
-
|
21
|
-
##
|
22
|
-
# @internal
|
23
|
-
# NOTE: Ruby hashes enumerate their values in the order that the corresponding keys were inserted.
|
24
|
-
# That is why the end-user can be 100% sure that the failure message is always generated from the first key/value pair.
|
25
|
-
# - https://ruby-doc.org/core-2.7.0/Hash.html
|
26
|
-
#
|
27
|
-
# TODO: A test that crashes when such behaviour is broken.
|
28
|
-
#
|
29
|
-
# NOTE: As a result, there is NO need to use any custom `OrderedHash` implementations.
|
30
|
-
# - https://api.rubyonrails.org/v5.1/classes/ActiveSupport/OrderedHash.html
|
31
|
-
# - https://github.com/rails/rails/issues/22681
|
32
|
-
# - https://api.rubyonrails.org/classes/ActiveSupport/OrderedOptions.html
|
33
|
-
#
|
34
|
-
def initialize(value:)
|
35
|
-
@value = value
|
36
|
-
end
|
37
|
-
|
38
|
-
##
|
39
|
-
# @param key [String, Symbol]
|
40
|
-
# @return [Boolean]
|
41
|
-
#
|
42
|
-
def has_attribute?(key)
|
43
|
-
value.has_key?(key.to_sym)
|
44
|
-
end
|
45
|
-
|
46
|
-
def ==(other)
|
47
|
-
casted = cast(other)
|
48
|
-
|
49
|
-
return unless casted
|
50
|
-
|
51
|
-
value == casted.value
|
52
|
-
end
|
53
|
-
|
54
|
-
def [](key)
|
55
|
-
value.fetch(key.to_sym) { raise Errors::NotExistingAttribute.new(attribute: key) }
|
56
|
-
end
|
57
|
-
|
58
|
-
def to_h
|
59
|
-
@to_h ||= value.to_h
|
60
|
-
end
|
61
|
-
|
62
|
-
def to_s
|
63
|
-
@to_s ||= to_h.to_s
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,34 +0,0 @@
|
|
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 ClassMethods
|
14
|
-
def cast(other)
|
15
|
-
case other
|
16
|
-
when ::String
|
17
|
-
new(value: other)
|
18
|
-
when ::Symbol
|
19
|
-
new(value: other.to_s)
|
20
|
-
when Message
|
21
|
-
new(value: other.value)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,45 +0,0 @@
|
|
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 Plugins
|
12
|
-
module HasJsendStatusAndAttributes
|
13
|
-
module Entities
|
14
|
-
class Message
|
15
|
-
include Support::Castable
|
16
|
-
|
17
|
-
extend ClassMethods
|
18
|
-
|
19
|
-
attr_reader :value
|
20
|
-
|
21
|
-
def initialize(value:)
|
22
|
-
@value = value
|
23
|
-
end
|
24
|
-
|
25
|
-
def ==(other)
|
26
|
-
casted = cast(other)
|
27
|
-
|
28
|
-
return unless casted
|
29
|
-
|
30
|
-
value == casted.value
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_s
|
34
|
-
@to_s ||= value.to_s
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,34 +0,0 @@
|
|
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 ClassMethods
|
14
|
-
def cast(other)
|
15
|
-
case other
|
16
|
-
when ::String
|
17
|
-
new(value: other.to_sym)
|
18
|
-
when ::Symbol
|
19
|
-
new(value: other)
|
20
|
-
when Status
|
21
|
-
new(value: other.value)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "status/class_methods"
|
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 Status
|
15
|
-
include Support::Castable
|
16
|
-
|
17
|
-
extend ClassMethods
|
18
|
-
|
19
|
-
attr_reader :value
|
20
|
-
|
21
|
-
def initialize(value:)
|
22
|
-
@value = value
|
23
|
-
end
|
24
|
-
|
25
|
-
def ==(other)
|
26
|
-
casted = cast(other)
|
27
|
-
|
28
|
-
return unless casted
|
29
|
-
|
30
|
-
value == casted.value
|
31
|
-
end
|
32
|
-
|
33
|
-
def success?
|
34
|
-
value == :success
|
35
|
-
end
|
36
|
-
|
37
|
-
def failure?
|
38
|
-
value == :failure
|
39
|
-
end
|
40
|
-
|
41
|
-
def error?
|
42
|
-
value == :error
|
43
|
-
end
|
44
|
-
|
45
|
-
def not_success?
|
46
|
-
!success?
|
47
|
-
end
|
48
|
-
|
49
|
-
def not_failure?
|
50
|
-
!failure?
|
51
|
-
end
|
52
|
-
|
53
|
-
def not_error?
|
54
|
-
!error?
|
55
|
-
end
|
56
|
-
|
57
|
-
def in?(statuses)
|
58
|
-
statuses.any? { |status| self == status }
|
59
|
-
end
|
60
|
-
|
61
|
-
def to_s
|
62
|
-
@to_s ||= value.to_s
|
63
|
-
end
|
64
|
-
|
65
|
-
def to_sym
|
66
|
-
@to_sym ||= value.to_sym
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "has_jsend_status_and_attributes/commands"
|
4
|
-
require_relative "has_jsend_status_and_attributes/concern"
|
5
|
-
require_relative "has_jsend_status_and_attributes/entities"
|
6
|
-
require_relative "has_jsend_status_and_attributes/errors"
|
7
|
-
require_relative "has_jsend_status_and_attributes/middleware"
|
8
|
-
require_relative "has_jsend_status_and_attributes/structs"
|