module ROM::Files::Plugins::Schema::Mime

A plugin for obtaining MIME-type of file using its name

@example Generic `mime_type` field

schema do
  use :mime_type
end

@api public

Constants

PROC
TYPE

Public Class Methods

apply(schema, name: :mime_type, type: TYPE) click to toggle source

@api private

# File lib/rom/files/plugins/schema/mime.rb, line 24
def self.apply(schema, name: :mime_type, type: TYPE)
  mime_type = type.meta(
    name: name,
    __proc__: PROC,
    source: schema.name
  )

  schema.attributes.concat(
    schema.class.attributes([mime_type], schema.attr_class)
  )
end