module Vox::HTTP::Util

@!visibility private

Public Instance Methods

filter_undef(hash) click to toggle source

Remove members from a hash that have `:undef` as values @example

hash = { foo: 1, bar: :undef, baz: 2 }
filter_hash(hash)
# => { foo: 1, baz: 2 }

@param hash [Hash] The hash to filter `:undef` members from. @return [Hash] The given hash with all members with an `:undef` value removed. @!visibility private

# File lib/vox/http/util.rb, line 17
def filter_undef(hash)
  hash.reject { |_, v| v == :undef }
end
mime_for_file(file) click to toggle source

Get the MIME type from a File object or path for UploadIO purposes @!visibility private @param file [File, String] File object or String for a file path. @return [String] Returns the MIME type for a file if any. Defaults to application/octet-stream

# File lib/vox/http/util.rb, line 25
def mime_for_file(file)
  path = file.is_a?(File) ? file.path : file
  MIME::Types.type_for(path)[0] || 'application/octet-stream'
end