lib/convenient_service/configs/minimal.rb in convenient_service-0.12.0 vs lib/convenient_service/configs/minimal.rb in convenient_service-0.13.0
- old
+ new
@@ -3,14 +3,34 @@
module ConvenientService
module Configs
##
# Defines minimal configuration that adds a constructor, JSend-inspired result, steps, basic inspects, and internals to services.
#
- # @note: This config is NOT intented for the end-user usage. Use `Standard` instead.
+ # @note This config is NOT intented for the end-user usage. Use `Standard` instead.
#
+ # @note
+ # `use Plugins::Common::NormalizesEnv::Middleware` should be used in a config that has the first `concern` that introduces a method.
+ # For example, `:result` is added by `use Plugins::Service::HasJSendResult::Concern` in `Minimal`.
+ # That is why the following code is written in the `Minimal` config.
+ #
+ # middlewares :result do
+ # use Plugins::Common::NormalizesEnv::Middleware
+ #
+ # # ...
+ # end
+ #
+ # In turn, `:fallback_result` is added by `use Plugins::Service::CanHaveFallback::Concern` in `Standard`.
+ # That is why it is the responsibility of the `Standard` config, to define:
+ #
+ # middlewares :fallback_result do
+ # use Plugins::Common::NormalizesEnv::Middleware
+ #
+ # # ...
+ # end
+ #
# @internal
- # Heavily used in specs to test concerns and middlewares in isolation.
+ # NOTE: Heavily used in specs to test concerns and middlewares in isolation.
#
module Minimal
include Support::Concern
##
@@ -32,21 +52,24 @@
use Plugins::Common::HasConstructor::Concern
use Plugins::Common::HasConstructorWithoutInitialize::Concern
use Plugins::Service::HasResult::Concern
+ use Plugins::Service::HasJSendResult::Concern
use Plugins::Service::CanHaveSteps::Concern
end
middlewares :initialize do
use Plugins::Common::NormalizesEnv::Middleware
end
middlewares :result do
use Plugins::Common::NormalizesEnv::Middleware
+ use Plugins::Common::CachesReturnValue::Middleware
- use Plugins::Service::HasResult::Middleware
+ use Plugins::Service::RaisesOnNotResultReturnValue::Middleware
+
use Plugins::Service::CanHaveSteps::Middleware
end
middlewares :step do
use Plugins::Common::NormalizesEnv::Middleware
@@ -70,11 +93,10 @@
middlewares :step, scope: :class do
use Plugins::Common::NormalizesEnv::Middleware
use Plugins::Service::CanHaveMethodSteps::Middleware
- use Plugins::Service::CanHaveResultStep::Middleware
end
class self::Internals
include Core
@@ -90,10 +112,11 @@
use Plugins::Common::HasInternals::Concern
use Plugins::Result::HasInspect::Concern
use Plugins::Common::HasConstructor::Concern
+ use Plugins::Common::HasConstructorWithoutInitialize::Concern
use Plugins::Result::HasJSendStatusAndAttributes::Concern
end
middlewares :initialize do
@@ -142,22 +165,38 @@
use Plugins::Common::NormalizesEnv::Middleware
end
class self::Data
include Core
+
+ concerns do
+ use Plugins::Data::HasInspect::Concern
+ end
end
class self::Message
include Core
+
+ concerns do
+ use Plugins::Message::HasInspect::Concern
+ end
end
class self::Code
include Core
+
+ concerns do
+ use Plugins::Code::HasInspect::Concern
+ end
end
class self::Status
include Core
+
+ concerns do
+ use Plugins::Status::HasInspect::Concern
+ end
end
class self::Internals
include Core
@@ -171,14 +210,37 @@
include Core
concerns do
use Plugins::Common::HasInternals::Concern
+ use Plugins::Step::CanBeCompleted::Concern
+
+ use Plugins::Step::CanBeMethodStep::Concern
+ use Plugins::Step::CanBeResultStep::Concern
+
use Plugins::Step::HasInspect::Concern
end
- middlewares :calculate_result do
+ middlewares :service_result do
use Plugins::Common::NormalizesEnv::Middleware
+ use Plugins::Common::CachesReturnValue::Middleware
+
+ use Plugins::Step::CanBeResultStep::CanBeExecuted::Middleware
+ use Plugins::Step::CanBeMethodStep::CanBeExecuted::Middleware
+ end
+
+ middlewares :result do
+ use Plugins::Common::NormalizesEnv::Middleware
+ use Plugins::Common::CachesReturnValue::Middleware
+ end
+
+ ##
+ # TODO: Rename.
+ #
+ middlewares :printable_service do
+ use Plugins::Common::NormalizesEnv::Middleware
+
+ use Plugins::Step::CanBeMethodStep::CanBePrinted::Middleware
end
class self::Internals
include Core