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.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/.dev/.tmuxinator.yml +2 -1
  3. data/.github/workflows/ci.yml +21 -1
  4. data/CHANGELOG.md +67 -0
  5. data/Gemfile +6 -0
  6. data/README.md +4 -2
  7. data/Taskfile.yml +94 -0
  8. data/convenient_service.gemspec +40 -2
  9. data/docker/2.7/Dockerfile +3 -3
  10. data/docker/3.0/Dockerfile +2 -2
  11. data/docker/3.1/Dockerfile +2 -2
  12. data/docker/3.2/Dockerfile +73 -0
  13. data/docker/jruby-9.4/Dockerfile +88 -0
  14. data/docker/truffleruby-22.3/Dockerfile +91 -0
  15. data/lib/convenient_service/common/plugins/aliases.rb +0 -1
  16. data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_active_model_attribute_assignment/middleware.rb +12 -8
  17. data/lib/convenient_service/common/plugins/caches_return_value/middleware.rb +3 -3
  18. data/lib/convenient_service/common/plugins/can_have_user_provided_entity/errors.rb +2 -2
  19. data/lib/convenient_service/common/plugins/has_around_callbacks/errors.rb +1 -1
  20. data/lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb +7 -7
  21. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/aliases.rb +7 -0
  22. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins.rb +2 -0
  23. data/lib/convenient_service/configs/minimal.rb +19 -10
  24. data/lib/convenient_service/core/class_methods.rb +24 -9
  25. data/lib/convenient_service/core/constants.rb +36 -0
  26. data/lib/convenient_service/core/entities/config/commands/track_method_missing_commit_trigger.rb +69 -0
  27. data/lib/convenient_service/core/entities/config/commands.rb +3 -0
  28. data/lib/convenient_service/core/entities/config/entities/concerns/entities/stack.rb +10 -10
  29. data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb +3 -3
  30. data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middleware.rb +18 -1
  31. data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middleware_creator.rb +62 -0
  32. data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/stack.rb +12 -12
  33. data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities.rb +1 -0
  34. data/lib/convenient_service/core/entities/config/entities/method_middlewares.rb +1 -1
  35. data/lib/convenient_service/core/entities/config/errors.rb +38 -1
  36. data/lib/convenient_service/core/entities/config.rb +14 -4
  37. data/lib/convenient_service/core/instance_methods.rb +6 -4
  38. data/lib/convenient_service/core.rb +1 -0
  39. data/lib/convenient_service/dependencies/built_in.rb +7 -0
  40. data/lib/convenient_service/dependencies/extractions/active_support_concern/concern.rb +18 -2
  41. data/lib/convenient_service/dependencies/extractions/active_support_concern.rb +4 -0
  42. data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/builder.rb +7 -1
  43. data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/logger.rb +7 -1
  44. data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/runner.rb +15 -1
  45. data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware.rb +8 -1
  46. data/lib/convenient_service/dependencies/extractions/ruby_middleware.rb +3 -2
  47. data/lib/convenient_service/dependencies.rb +16 -15
  48. data/lib/convenient_service/examples/dry/gemfile.rb +4 -4
  49. data/lib/convenient_service/examples/rails/gemfile.rb +4 -4
  50. data/lib/convenient_service/examples/standard/cowsay.rb +4 -4
  51. data/lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb +1 -1
  52. data/lib/convenient_service/examples/standard/gemfile/services/assert_file_not_empty.rb +1 -1
  53. data/lib/convenient_service/examples/standard/gemfile/services/assert_node_available.rb +0 -9
  54. data/lib/convenient_service/examples/standard/gemfile/services/assert_npm_package_available.rb +0 -10
  55. data/lib/convenient_service/examples/standard/gemfile/services/format.rb +0 -10
  56. data/lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb +0 -10
  57. data/lib/convenient_service/examples/standard/gemfile/services/parse_content.rb +0 -10
  58. data/lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb +0 -10
  59. data/lib/convenient_service/examples/standard/gemfile/services/replace_file_content.rb +0 -10
  60. data/lib/convenient_service/examples/standard/gemfile.rb +4 -4
  61. data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_body.rb +0 -10
  62. data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path.rb +0 -10
  63. data/lib/convenient_service/examples/standard/request_params/services/validate_casted_params.rb +0 -10
  64. data/lib/convenient_service/examples/standard/request_params/services/validate_uncasted_params.rb +0 -10
  65. data/lib/convenient_service/examples/standard/request_params.rb +4 -4
  66. data/lib/convenient_service/feature.rb +12 -0
  67. data/lib/convenient_service/logger.rb +6 -5
  68. data/lib/convenient_service/rspec/helpers/custom/in_threads.rb +74 -0
  69. data/lib/convenient_service/rspec/helpers/custom/stub_service/constants.rb +20 -0
  70. data/lib/convenient_service/rspec/helpers/custom/stub_service/entities/stubbed_service.rb +4 -4
  71. data/lib/convenient_service/rspec/helpers/custom/stub_service.rb +1 -0
  72. data/lib/convenient_service/rspec/helpers/custom/wrap_method/entities/wrapped_method.rb +3 -3
  73. data/lib/convenient_service/rspec/helpers/custom/wrap_method/errors.rb +1 -1
  74. data/lib/convenient_service/rspec/helpers/custom.rb +1 -0
  75. data/lib/convenient_service/rspec/helpers/in_threads.rb +13 -0
  76. data/lib/convenient_service/rspec/helpers.rb +2 -0
  77. data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings_collection/errors.rb +3 -3
  78. data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/delegation.rb +3 -3
  79. data/lib/convenient_service/rspec/matchers/custom/export.rb +82 -0
  80. data/lib/convenient_service/rspec/matchers/custom/results/base/constants.rb +22 -0
  81. data/lib/convenient_service/rspec/matchers/custom/results/base/errors.rb +1 -1
  82. data/lib/convenient_service/rspec/matchers/custom/results/base.rb +2 -1
  83. data/lib/convenient_service/rspec/matchers/custom.rb +1 -0
  84. data/lib/convenient_service/rspec/matchers/export.rb +13 -0
  85. data/lib/convenient_service/rspec/matchers.rb +2 -0
  86. data/lib/convenient_service/service/plugins/aliases.rb +0 -2
  87. data/lib/convenient_service/service/plugins/can_have_method_steps/middleware.rb +2 -2
  88. data/lib/convenient_service/service/plugins/can_have_result_step/middleware.rb +2 -2
  89. data/lib/convenient_service/service/plugins/can_have_steps/concern.rb +2 -2
  90. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method.rb +46 -11
  91. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_direction.rb +29 -2
  92. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_factory.rb +113 -0
  93. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands.rb +1 -3
  94. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/base.rb +62 -0
  95. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/base.rb +35 -0
  96. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/proc_value.rb +42 -0
  97. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/raw_value.rb +42 -0
  98. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/reassignment_value.rb +42 -0
  99. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/string_value.rb +42 -0
  100. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/symbol_value.rb +42 -0
  101. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash.rb +8 -0
  102. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/method.rb +40 -0
  103. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/reassignment.rb +40 -0
  104. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/string.rb +40 -0
  105. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/symbol.rb +40 -0
  106. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories.rb +8 -0
  107. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities.rb +1 -0
  108. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/errors.rb +7 -7
  109. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/errors.rb +12 -8
  110. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/aliases.rb +7 -0
  111. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +2 -0
  112. data/lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb +37 -8
  113. data/lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb +19 -11
  114. data/lib/convenient_service/service/plugins/can_have_stubbed_result/middleware.rb +3 -3
  115. data/lib/convenient_service/service/plugins/has_result/concern/instance_methods.rb +3 -3
  116. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/aliases.rb +7 -0
  117. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/concern.rb +12 -5
  118. 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
  119. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result.rb +1 -0
  120. 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
  121. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_code_class.rb +49 -0
  122. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_data_class.rb +49 -0
  123. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_message_class.rb +49 -0
  124. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_status_class.rb +49 -0
  125. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands.rb +7 -0
  126. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/concern/class_methods.rb +69 -0
  127. 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
  128. 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
  129. 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
  130. 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
  131. 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
  132. 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
  133. 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
  134. 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
  135. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern.rb +36 -0
  136. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data.rb +25 -0
  137. 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
  138. 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
  139. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/concern.rb +36 -0
  140. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message.rb +25 -0
  141. 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
  142. 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
  143. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern.rb +36 -0
  144. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status.rb +25 -0
  145. 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
  146. 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
  147. 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
  148. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/structs.rb +3 -0
  149. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes.rb +8 -0
  150. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax/concern.rb +3 -3
  151. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/raises_on_not_checked_result_status/errors.rb +1 -1
  152. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins.rb +3 -1
  153. data/lib/convenient_service/service/plugins/has_result/errors.rb +2 -2
  154. data/lib/convenient_service/service/plugins/has_result_status_check_short_syntax/concern.rb +16 -0
  155. data/lib/convenient_service/service/plugins/raises_on_double_result/errors.rb +1 -1
  156. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb +1 -1
  157. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_exception.rb +11 -10
  158. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb +14 -7
  159. data/lib/convenient_service/services/run_own_method_in_organizer.rb +1 -1
  160. data/lib/convenient_service/support/abstract_method/errors.rb +1 -1
  161. data/lib/convenient_service/support/arguments.rb +3 -3
  162. data/lib/convenient_service/support/cache/key.rb +3 -3
  163. data/lib/convenient_service/support/cache.rb +1 -1
  164. data/lib/convenient_service/support/castable/errors.rb +2 -2
  165. data/lib/convenient_service/support/counter.rb +212 -0
  166. data/lib/convenient_service/support/dependency_container/commands/assert_valid_container.rb +33 -0
  167. data/lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb +58 -0
  168. data/lib/convenient_service/support/dependency_container/commands/assert_valid_scope.rb +4 -3
  169. data/lib/convenient_service/support/dependency_container/commands/define_entry.rb +49 -0
  170. data/lib/convenient_service/support/dependency_container/commands.rb +3 -0
  171. data/lib/convenient_service/support/dependency_container/container.rb +23 -0
  172. data/lib/convenient_service/support/dependency_container/entry.rb +22 -0
  173. data/lib/convenient_service/support/dependency_container/errors.rb +5 -5
  174. data/lib/convenient_service/support/dependency_container/import.rb +3 -3
  175. data/lib/convenient_service/support/dependency_container.rb +3 -0
  176. data/lib/convenient_service/support/finite_loop.rb +37 -2
  177. data/lib/convenient_service/support/middleware/stack_builder.rb +1 -1
  178. data/lib/convenient_service/support/not_passed.rb +4 -3
  179. data/lib/convenient_service/support/ruby.rb +31 -0
  180. data/lib/convenient_service/support/safe_method.rb +65 -0
  181. data/lib/convenient_service/support/thread_safe_counter.rb +119 -0
  182. data/lib/convenient_service/support/undefined.rb +4 -3
  183. data/lib/convenient_service/support/unique_value.rb +69 -0
  184. data/lib/convenient_service/support.rb +4 -0
  185. data/lib/convenient_service/utils/array/errors.rb +1 -1
  186. data/lib/convenient_service/utils/array/find_last.rb +1 -1
  187. data/lib/convenient_service/utils/array/find_yield.rb +1 -1
  188. data/lib/convenient_service/utils/object/resolve_class.rb +56 -0
  189. data/lib/convenient_service/utils/object.rb +9 -0
  190. data/lib/convenient_service/version.rb +1 -1
  191. data/lib/convenient_service.rb +6 -0
  192. metadata +75 -34
  193. data/lib/convenient_service/factories/arguments.rb +0 -43
  194. data/lib/convenient_service/factories/results.rb +0 -214
  195. data/lib/convenient_service/factories/services.rb +0 -229
  196. data/lib/convenient_service/factories/step/instance.rb +0 -42
  197. data/lib/convenient_service/factories/step.rb +0 -3
  198. data/lib/convenient_service/factories/steps.rb +0 -126
  199. data/lib/convenient_service/factories.rb +0 -22
  200. data/lib/convenient_service/factory.rb +0 -21
  201. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_caller.rb +0 -74
  202. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_key.rb +0 -78
  203. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_name.rb +0 -78
  204. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands.rb +0 -3
  205. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data/class_methods.rb +0 -32
  206. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data.rb +0 -74
  207. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message/class_methods.rb +0 -34
  208. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message.rb +0 -45
  209. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status/class_methods.rb +0 -34
  210. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb +0 -77
  211. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs.rb +0 -3
  212. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes.rb +0 -8
  213. /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,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "structs/jsend_attributes"
@@ -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"