Sha256: bddfb4db6555e6fcef602aa325bbc9b63b9386335486da848ce55da8c6fdeca0
Contents?: true
Size: 671 Bytes
Versions: 26
Compression:
Stored size: 671 Bytes
Contents
# typed: ignore require 'sorbet-coerce' if !$PROGRAM_NAME.include?('sorbet') module TypedParams # A sorbet-coerce wrapper for coercing typed controller parameters define_singleton_method(:[]) do |type| Class.new do define_method(:extract!) do |params, raise_coercion_error: nil| begin TypeCoerce[type].new.from( params.permit!.to_h, raise_coercion_error: raise_coercion_error ) rescue TypeCoerce::CoercionError, TypeCoerce::ShapeError, TypeError, ArgumentError => e raise ActionController::BadRequest.new(e) end end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems