Class: Shrine::Plugins::TypePredicates::MimeDatabase

Inherits:
Object
  • Object
show all
Defined in:
lib/shrine/plugins/type_predicates.rb

Constant Summary collapse

SUPPORTED_TOOLS =
%i[mini_mime mime_types mimemagic marcel rack_mime]

Instance Method Summary collapse

Constructor Details

#initialize(tool) ⇒ MimeDatabase

Returns a new instance of MimeDatabase.

Raises:



63
64
65
66
67
# File 'lib/shrine/plugins/type_predicates.rb', line 63

def initialize(tool)
  raise Error, "unknown type database #{tool.inspect}, supported databases are: #{SUPPORTED_TOOLS.join(",")}" unless SUPPORTED_TOOLS.include?(tool)

  @tool = tool
end

Instance Method Details

#call(extension) ⇒ Object



69
70
71
# File 'lib/shrine/plugins/type_predicates.rb', line 69

def call(extension)
  send(:"lookup_with_#{@tool}", extension)
end