convenient_service 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +58 -0
  3. data/ROADMAP.md +14 -1
  4. data/convenient_service.gemspec +2 -1
  5. data/lib/convenient_service/aliases.rb +10 -0
  6. data/lib/convenient_service/common/plugins/has_around_callbacks/middleware.rb +24 -4
  7. data/lib/convenient_service/common/plugins/has_callbacks/container.rb +17 -0
  8. data/lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb +98 -5
  9. data/lib/convenient_service/common/plugins/has_callbacks/middleware.rb +25 -4
  10. data/lib/convenient_service/common/plugins/has_callbacks.rb +1 -0
  11. data/lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb +19 -0
  12. data/lib/convenient_service/common/plugins.rb +1 -1
  13. data/lib/convenient_service/configs/minimal.rb +176 -0
  14. data/lib/convenient_service/configs/standard.rb +30 -105
  15. data/lib/convenient_service/configs.rb +1 -0
  16. data/lib/convenient_service/dependencies.rb +20 -0
  17. data/lib/convenient_service/examples/dry/gemfile/dry_service/config.rb +5 -5
  18. data/lib/convenient_service/examples/rails/gemfile/rails_service/config.rb +7 -7
  19. data/lib/convenient_service/examples/rails/gemfile/services/format.rb +35 -6
  20. data/lib/convenient_service/examples/rails/gemfile/services/format_header.rb +1 -2
  21. data/lib/convenient_service/examples/rails/gemfile/services/merge_sections.rb +25 -0
  22. data/lib/convenient_service/examples/rails/gemfile/services/replace_file_content.rb +37 -0
  23. data/lib/convenient_service/examples/rails/gemfile/services.rb +8 -4
  24. data/lib/convenient_service/examples/standard/gemfile/services/format.rb +45 -6
  25. data/lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb +52 -0
  26. data/lib/convenient_service/examples/standard/gemfile/services/replace_file_content.rb +48 -0
  27. data/lib/convenient_service/examples/standard/gemfile/services.rb +8 -4
  28. data/lib/convenient_service/factories/arguments.rb +43 -0
  29. data/lib/convenient_service/factories/results.rb +214 -0
  30. data/lib/convenient_service/factories/services.rb +189 -0
  31. data/lib/convenient_service/factories/step/instance.rb +32 -0
  32. data/lib/convenient_service/factories/step.rb +3 -0
  33. data/lib/convenient_service/factories/steps.rb +126 -0
  34. data/lib/convenient_service/factories.rb +22 -0
  35. data/lib/convenient_service/factory.rb +21 -0
  36. data/lib/convenient_service/rspec/helpers/custom/ignoring_error.rb +3 -0
  37. data/lib/convenient_service/rspec/helpers/custom/wrap_method/entities/wrapped_method.rb +29 -3
  38. data/lib/convenient_service/rspec/matchers/custom/be_descendant_of.rb +2 -2
  39. data/lib/convenient_service/rspec/matchers/custom/be_direct_descendant_of.rb +2 -2
  40. data/lib/convenient_service/rspec/matchers/custom/delegate_to.rb +9 -0
  41. data/lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_method_step.rb +74 -0
  42. data/lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_result_method_step.rb +66 -0
  43. data/lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_service_step.rb +48 -0
  44. data/lib/convenient_service/rspec/matchers/custom/results/base/commands/generate_expected_step_part.rb +42 -0
  45. data/lib/convenient_service/rspec/matchers/custom/results/base/commands/generate_got_step_part.rb +42 -0
  46. data/lib/convenient_service/rspec/matchers/custom/results/base/commands/match_result_step.rb +89 -0
  47. data/lib/convenient_service/rspec/matchers/custom/results/base/commands.rb +10 -0
  48. data/lib/convenient_service/rspec/matchers/custom/results/base/errors.rb +35 -0
  49. data/lib/convenient_service/rspec/matchers/custom/results/base.rb +78 -12
  50. data/lib/convenient_service/service/plugins/has_result/concern/class_methods.rb +3 -3
  51. data/lib/convenient_service/service/plugins/has_result/constants.rb +0 -3
  52. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/concern.rb +85 -0
  53. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/initialize/middleware.rb +27 -0
  54. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/initialize.rb +3 -0
  55. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/to_kwargs/middleware.rb +25 -0
  56. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/to_kwargs.rb +3 -0
  57. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result.rb +5 -0
  58. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/concern/instance_methods.rb +7 -1
  59. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data.rb +17 -0
  60. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step/concern.rb +27 -0
  61. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step/initialize/middleware.rb +27 -0
  62. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step/initialize.rb +3 -0
  63. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step/to_kwargs/middleware.rb +25 -0
  64. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step/to_kwargs.rb +3 -0
  65. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step.rb +5 -0
  66. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins.rb +2 -0
  67. data/lib/convenient_service/service/plugins/has_result_method_steps.rb +0 -2
  68. data/lib/convenient_service/service/plugins/has_result_steps/concern.rb +18 -7
  69. data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/define_method_in_container.rb +2 -2
  70. data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers/reassignment/commands/define_method_in_container.rb +1 -1
  71. data/lib/convenient_service/service/plugins/has_result_steps/entities/step/concern/instance_methods.rb +26 -1
  72. data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/can_have_parent_result/middleware.rb +23 -0
  73. data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/can_have_parent_result.rb +3 -0
  74. data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins.rb +1 -0
  75. data/lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb +13 -0
  76. data/lib/convenient_service/service/plugins/has_result_steps/middleware.rb +18 -4
  77. data/lib/convenient_service/service/plugins/raises_on_double_result/middleware.rb +37 -2
  78. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb +80 -0
  79. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_cause.rb +78 -0
  80. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_exception.rb +169 -0
  81. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_line.rb +40 -0
  82. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands.rb +7 -0
  83. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/constants.rb +13 -0
  84. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb +58 -0
  85. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions.rb +5 -0
  86. data/lib/convenient_service/services/run_method_in_organizer.rb +28 -0
  87. data/lib/convenient_service/services/run_own_method_in_organizer.rb +64 -0
  88. data/lib/convenient_service/{service/plugins/has_result_method_steps/services.rb → services.rb} +0 -1
  89. data/lib/convenient_service/support/copyable.rb +6 -2
  90. data/lib/convenient_service/support/dependency_container/errors.rb +1 -1
  91. data/lib/convenient_service/support/not_passed.rb +3 -1
  92. data/lib/convenient_service/support/undefined.rb +9 -0
  93. data/lib/convenient_service/support.rb +2 -0
  94. data/lib/convenient_service/version.rb +1 -1
  95. data/lib/convenient_service.rb +6 -0
  96. data/logo.png +0 -0
  97. metadata +68 -11
  98. data/lib/convenient_service/service/plugins/has_result_method_steps/errors.rb +0 -23
  99. data/lib/convenient_service/service/plugins/has_result_method_steps/services/method_step_config.rb +0 -55
  100. data/lib/convenient_service/service/plugins/has_result_method_steps/services/run_method_in_organizer.rb +0 -30
  101. data/lib/convenient_service/service/plugins/has_result_method_steps/services/run_own_method_in_organizer.rb +0 -52
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convenient_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marian Kostyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-22 00:00:00.000000000 Z
11
+ date: 2023-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faker
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: gem-release
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -294,16 +308,16 @@ dependencies:
294
308
  name: yard
295
309
  requirement: !ruby/object:Gem::Requirement
296
310
  requirements:
297
- - - ">="
311
+ - - "~>"
298
312
  - !ruby/object:Gem::Version
299
- version: '0'
313
+ version: 0.9.28
300
314
  type: :development
301
315
  prerelease: false
302
316
  version_requirements: !ruby/object:Gem::Requirement
303
317
  requirements:
304
- - - ">="
318
+ - - "~>"
305
319
  - !ruby/object:Gem::Version
306
- version: '0'
320
+ version: 0.9.28
307
321
  - !ruby/object:Gem::Dependency
308
322
  name: yard-junk
309
323
  requirement: !ruby/object:Gem::Requirement
@@ -387,6 +401,7 @@ files:
387
401
  - lib/convenient_service/common/plugins/has_attributes/using_active_model_attributes/patches/active_model_attributes.rb
388
402
  - lib/convenient_service/common/plugins/has_callbacks.rb
389
403
  - lib/convenient_service/common/plugins/has_callbacks/concern.rb
404
+ - lib/convenient_service/common/plugins/has_callbacks/container.rb
390
405
  - lib/convenient_service/common/plugins/has_callbacks/entities.rb
391
406
  - lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb
392
407
  - lib/convenient_service/common/plugins/has_callbacks/entities/callback_collection.rb
@@ -412,6 +427,7 @@ files:
412
427
  - lib/convenient_service/common/plugins/normalizes_env/middleware.rb
413
428
  - lib/convenient_service/configs.rb
414
429
  - lib/convenient_service/configs/aliases.rb
430
+ - lib/convenient_service/configs/minimal.rb
415
431
  - lib/convenient_service/configs/standard.rb
416
432
  - lib/convenient_service/core.rb
417
433
  - lib/convenient_service/core/aliases.rb
@@ -496,9 +512,11 @@ files:
496
512
  - lib/convenient_service/examples/rails/gemfile/services/format_gems_with_envs.rb
497
513
  - lib/convenient_service/examples/rails/gemfile/services/format_gems_without_envs.rb
498
514
  - lib/convenient_service/examples/rails/gemfile/services/format_header.rb
515
+ - lib/convenient_service/examples/rails/gemfile/services/merge_sections.rb
499
516
  - lib/convenient_service/examples/rails/gemfile/services/parse_content.rb
500
517
  - lib/convenient_service/examples/rails/gemfile/services/print_shell_command.rb
501
518
  - lib/convenient_service/examples/rails/gemfile/services/read_file_content.rb
519
+ - lib/convenient_service/examples/rails/gemfile/services/replace_file_content.rb
502
520
  - lib/convenient_service/examples/rails/gemfile/services/run_shell.rb
503
521
  - lib/convenient_service/examples/rails/gemfile/services/strip_comments.rb
504
522
  - lib/convenient_service/examples/standard/cowsay.rb
@@ -518,9 +536,11 @@ files:
518
536
  - lib/convenient_service/examples/standard/gemfile/services/format_gems_with_envs.rb
519
537
  - lib/convenient_service/examples/standard/gemfile/services/format_gems_without_envs.rb
520
538
  - lib/convenient_service/examples/standard/gemfile/services/format_header.rb
539
+ - lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb
521
540
  - lib/convenient_service/examples/standard/gemfile/services/parse_content.rb
522
541
  - lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb
523
542
  - lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
543
+ - lib/convenient_service/examples/standard/gemfile/services/replace_file_content.rb
524
544
  - lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
525
545
  - lib/convenient_service/examples/standard/gemfile/services/strip_comments.rb
526
546
  - lib/convenient_service/examples/standard/request_params.rb
@@ -559,6 +579,14 @@ files:
559
579
  - lib/convenient_service/examples/standard/request_params/utils/object.rb
560
580
  - lib/convenient_service/examples/standard/request_params/utils/object/blank.rb
561
581
  - lib/convenient_service/examples/standard/request_params/utils/object/present.rb
582
+ - lib/convenient_service/factories.rb
583
+ - lib/convenient_service/factories/arguments.rb
584
+ - lib/convenient_service/factories/results.rb
585
+ - lib/convenient_service/factories/services.rb
586
+ - lib/convenient_service/factories/step.rb
587
+ - lib/convenient_service/factories/step/instance.rb
588
+ - lib/convenient_service/factories/steps.rb
589
+ - lib/convenient_service/factory.rb
562
590
  - lib/convenient_service/logger.rb
563
591
  - lib/convenient_service/rspec.rb
564
592
  - lib/convenient_service/rspec/helpers.rb
@@ -617,6 +645,14 @@ files:
617
645
  - lib/convenient_service/rspec/matchers/custom/prepend_module.rb
618
646
  - lib/convenient_service/rspec/matchers/custom/results.rb
619
647
  - lib/convenient_service/rspec/matchers/custom/results/base.rb
648
+ - lib/convenient_service/rspec/matchers/custom/results/base/commands.rb
649
+ - lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_method_step.rb
650
+ - lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_result_method_step.rb
651
+ - lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_service_step.rb
652
+ - lib/convenient_service/rspec/matchers/custom/results/base/commands/generate_expected_step_part.rb
653
+ - lib/convenient_service/rspec/matchers/custom/results/base/commands/generate_got_step_part.rb
654
+ - lib/convenient_service/rspec/matchers/custom/results/base/commands/match_result_step.rb
655
+ - lib/convenient_service/rspec/matchers/custom/results/base/errors.rb
620
656
  - lib/convenient_service/rspec/matchers/custom/results/be_error.rb
621
657
  - lib/convenient_service/rspec/matchers/custom/results/be_failure.rb
622
658
  - lib/convenient_service/rspec/matchers/custom/results/be_not_error.rb
@@ -662,6 +698,12 @@ files:
662
698
  - lib/convenient_service/service/plugins/has_result/entities/result.rb
663
699
  - lib/convenient_service/service/plugins/has_result/entities/result/concern.rb
664
700
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins.rb
701
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result.rb
702
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/concern.rb
703
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/initialize.rb
704
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/initialize/middleware.rb
705
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/to_kwargs.rb
706
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/to_kwargs/middleware.rb
665
707
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_recalculate_result.rb
666
708
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_recalculate_result/concern.rb
667
709
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_inspect.rb
@@ -687,6 +729,12 @@ files:
687
729
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax.rb
688
730
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax/concern.rb
689
731
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax/concern/instance_methods.rb
732
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step.rb
733
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step/concern.rb
734
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step/initialize.rb
735
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step/initialize/middleware.rb
736
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step/to_kwargs.rb
737
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_step/to_kwargs/middleware.rb
690
738
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/marks_result_status_as_checked.rb
691
739
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/marks_result_status_as_checked/middleware.rb
692
740
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/raises_on_not_checked_result_status.rb
@@ -695,12 +743,7 @@ files:
695
743
  - lib/convenient_service/service/plugins/has_result/errors.rb
696
744
  - lib/convenient_service/service/plugins/has_result/middleware.rb
697
745
  - lib/convenient_service/service/plugins/has_result_method_steps.rb
698
- - lib/convenient_service/service/plugins/has_result_method_steps/errors.rb
699
746
  - lib/convenient_service/service/plugins/has_result_method_steps/middleware.rb
700
- - lib/convenient_service/service/plugins/has_result_method_steps/services.rb
701
- - lib/convenient_service/service/plugins/has_result_method_steps/services/method_step_config.rb
702
- - lib/convenient_service/service/plugins/has_result_method_steps/services/run_method_in_organizer.rb
703
- - lib/convenient_service/service/plugins/has_result_method_steps/services/run_own_method_in_organizer.rb
704
747
  - lib/convenient_service/service/plugins/has_result_params_validations/using_active_model_validations.rb
705
748
  - lib/convenient_service/service/plugins/has_result_params_validations/using_active_model_validations/concern.rb
706
749
  - lib/convenient_service/service/plugins/has_result_params_validations/using_active_model_validations/middleware.rb
@@ -772,6 +815,8 @@ files:
772
815
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/concern/instance_methods.rb
773
816
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/errors.rb
774
817
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins.rb
818
+ - lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/can_have_parent_result.rb
819
+ - lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/can_have_parent_result/middleware.rb
775
820
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/has_inspect.rb
776
821
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/has_inspect/concern.rb
777
822
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/structs.rb
@@ -781,8 +826,19 @@ files:
781
826
  - lib/convenient_service/service/plugins/raises_on_double_result.rb
782
827
  - lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
783
828
  - lib/convenient_service/service/plugins/raises_on_double_result/middleware.rb
829
+ - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions.rb
830
+ - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands.rb
831
+ - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb
832
+ - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_cause.rb
833
+ - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_exception.rb
834
+ - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_line.rb
835
+ - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/constants.rb
836
+ - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb
784
837
  - lib/convenient_service/service/plugins/wraps_result_in_db_transaction.rb
785
838
  - lib/convenient_service/service/plugins/wraps_result_in_db_transaction/middleware.rb
839
+ - lib/convenient_service/services.rb
840
+ - lib/convenient_service/services/run_method_in_organizer.rb
841
+ - lib/convenient_service/services/run_own_method_in_organizer.rb
786
842
  - lib/convenient_service/specification.rb
787
843
  - lib/convenient_service/support.rb
788
844
  - lib/convenient_service/support/abstract_method.rb
@@ -820,6 +876,7 @@ files:
820
876
  - lib/convenient_service/support/not_passed.rb
821
877
  - lib/convenient_service/support/raw_value.rb
822
878
  - lib/convenient_service/support/ruby.rb
879
+ - lib/convenient_service/support/undefined.rb
823
880
  - lib/convenient_service/support/version.rb
824
881
  - lib/convenient_service/support/version/null_version.rb
825
882
  - lib/convenient_service/utils.rb
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Service
5
- module Plugins
6
- module HasResultMethodSteps
7
- module Errors
8
- class MethodForStepIsNotDefined < ConvenientService::Error
9
- def initialize(service_class:, method_name:)
10
- message = <<~TEXT
11
- Service #{service_class} tries to use `#{method_name}` method in a step, but it NOT defined.
12
-
13
- Did you forget to define it?
14
- TEXT
15
-
16
- super(message)
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Service
5
- module Plugins
6
- module HasResultMethodSteps
7
- module Services
8
- module MethodStepConfig
9
- include Support::Concern
10
-
11
- # rubocop:disable Lint/ConstantDefinitionInBlock
12
- included do
13
- include ConvenientService::Core
14
-
15
- concerns do
16
- use ConvenientService::Service::Plugins::HasResult::Concern
17
- end
18
-
19
- middlewares :result do
20
- use ConvenientService::Common::Plugins::NormalizesEnv::Middleware
21
-
22
- use ConvenientService::Service::Plugins::HasResult::Middleware
23
- end
24
-
25
- class self::Result
26
- include ConvenientService::Core
27
-
28
- concerns do
29
- use ConvenientService::Common::Plugins::HasInternals::Concern
30
- use ConvenientService::Common::Plugins::HasConstructor::Concern
31
- use ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJsendStatusAndAttributes::Concern
32
- end
33
-
34
- middlewares :initialize do
35
- use ConvenientService::Common::Plugins::NormalizesEnv::Middleware
36
-
37
- use ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins::HasJsendStatusAndAttributes::Middleware
38
- end
39
-
40
- class self::Internals
41
- include ConvenientService::Core
42
-
43
- concerns do
44
- use ConvenientService::Common::Plugins::HasInternals::Entities::Internals::Plugins::HasCache::Concern
45
- end
46
- end
47
- end
48
- end
49
- # rubocop:enable Lint/ConstantDefinitionInBlock
50
- end
51
- end
52
- end
53
- end
54
- end
55
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Service
5
- module Plugins
6
- module HasResultMethodSteps
7
- module Services
8
- class RunMethodInOrganizer
9
- include MethodStepConfig
10
-
11
- attr_reader :method_name, :organizer, :kwargs
12
-
13
- def initialize(method_name:, organizer:, **kwargs)
14
- @method_name = method_name
15
- @organizer = organizer
16
- @kwargs = kwargs
17
- end
18
-
19
- def result
20
- ##
21
- # NOTE: `kwargs` are intentionally NOT passed, since all the corresponding methods are available inside `organizer.__send__(method_name)` body.
22
- #
23
- organizer.__send__(method_name)
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Service
5
- module Plugins
6
- module HasResultMethodSteps
7
- module Services
8
- class RunOwnMethodInOrganizer
9
- include MethodStepConfig
10
-
11
- attr_reader :method_name, :organizer, :kwargs
12
-
13
- def initialize(method_name:, organizer:, **kwargs)
14
- @method_name = method_name
15
- @organizer = organizer
16
- @kwargs = kwargs
17
- end
18
-
19
- def result
20
- raise Errors::MethodForStepIsNotDefined.new(service_class: organizer.class, method_name: method_name) unless own_method
21
-
22
- ##
23
- # NOTE: `kwargs` are intentionally NOT passed, since all the corresponding methods are available inside `own_method` body.
24
- #
25
- own_method.call
26
- end
27
-
28
- private
29
-
30
- ##
31
- # @return [Method, nil]
32
- #
33
- # @internal
34
- # TODO: A possible bottleneck. Should be removed if receives negative feedback.
35
- #
36
- # NOTE: `own_method.bind(organizer).call` is logically the same as `own_method.bind_call(organizer)`.
37
- # - https://ruby-doc.org/core-2.7.1/UnboundMethod.html#method-i-bind_call
38
- # - https://blog.saeloun.com/2019/10/17/ruby-2-7-adds-unboundmethod-bind_call-method.html
39
- #
40
- def own_method
41
- method = Utils::Module.get_own_instance_method(organizer.class, method_name, private: true)
42
-
43
- return unless method
44
-
45
- method.bind(organizer)
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end