Class: ConvenientService::Common::Plugins::NormalizesEnv::Middleware
- Inherits:
-
MethodClassicMiddleware
- Object
- ConvenientService::Common::Plugins::NormalizesEnv::Middleware
- Defined in:
- lib/convenient_service/common/plugins/normalizes_env/middleware.rb
Overview
-
Single splat ‘*` converts
nilto empty array. -
Double splat ‘**` raises on
nil. -
Umpersand ‘&` converts
niltonil.
The following middleware converts env[:kwargs] to a hash. This way ‘stack.call(*env, **env, &env)` won’t fail even if a user passes nil as kwargs.
Check the following link for more details:
Instance Method Summary collapse
Instance Method Details
#call(env = nil) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/convenient_service/common/plugins/normalizes_env/middleware.rb', line 21 def call(env = nil) env = env.to_h env = env.merge(args: env[:args].to_a, kwargs: env[:kwargs].to_h, block: env[:block]) stack.call(env) end |