Sha256: 8887752472a94e21b49a07a3fffd1ef4ecbd897ddc8a77f487feb39ad3b771df
Contents?: true
Size: 921 Bytes
Versions: 9
Compression:
Stored size: 921 Bytes
Contents
module Grape module Validations module Types # +Virtus::Attribute+ implementation for parameters # that are multipart file objects. Actual handling # of these objects is provided by +Rack::Request+; # this class is here only to assert that rack's # handling has succeeded, and to prevent virtus # from interfering. class File < Virtus::Attribute def coerce(input) # Processing of multipart file objects # is already taken care of by Rack::Request. # Nothing to do here. input end def value_coerced?(value) # Rack::Request creates a Hash with filename, # content type and an IO object. Grape wraps that # using hashie for convenience. Do a bit of basic # duck-typing. value.is_a?(Hashie::Mash) && value.key?(:tempfile) end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems