Sha256: d49589780952fae5d2e4224ef5eee5aac62de992913c82e0628f34b86cdeff8a
Contents?: true
Size: 980 Bytes
Versions: 6
Compression:
Stored size: 980 Bytes
Contents
# frozen_string_literal: true module ConvenientService module Common module Plugins module NormalizesEnv ## # - Single splat `*` converts `nil` to empty array. # - Double splat `**` raises on `nil`. # - Umpersand `&` converts `nil` to `nil`. # # The following middleware converts `env[:kwargs]` to a hash. # This way `stack.call(*env[:args], **env[:kwargs], &env[:block])` won't fail even if a user passes `nil` as `kwargs`. # # Check the following link for more details: # - https://bugs.ruby-lang.org/issues/8507 # class Middleware < MethodClassicMiddleware intended_for any_method, scope: any_scope, entity: any_entity 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 end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems