Sha256: ad092d64c3e479dfc463c92934d0c9b4adc32b57206ad64787a040991a6ea032
Contents?: true
Size: 907 Bytes
Versions: 15
Compression:
Stored size: 907 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 < Core::ClassicMiddleware 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
15 entries across 15 versions & 1 rubygems