Module: Rack::RDF

Defined in:
lib/rack/rdf.rb,
lib/rack/rdf/conneg.rb,
lib/rack/rdf/version.rb

Defined Under Namespace

Modules: VERSION Classes: ContentNegotiation

Class Method Summary collapse

Class Method Details

.register_mime_types!(overwrite: false, **options)

This method returns an undefined value.

Registers all known RDF formats with Rack’s MIME types registry.

Parameters:

  • overwrite (Boolean) (defaults to: false)

    (false)

  • options (Hash{Symbol => Object})


17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rack/rdf.rb', line 17

def self.register_mime_types!(overwrite: false, **options)
  if defined?(Rack::Mime::MIME_TYPES)
    ::RDF::Format.each do |format|
      if !Rack::Mime::MIME_TYPES.has_key?(file_ext = ".#{format.to_sym}") || overwrite
        Rack::Mime::MIME_TYPES.merge!(file_ext => format.content_type.first)
      end
    end
    ::RDF::Format.file_extensions.each do |file_ext, formats|
      if !Rack::Mime::MIME_TYPES.has_key?(file_ext = ".#{file_ext}") || overwrite
        Rack::Mime::MIME_TYPES.merge!(file_ext => formats.first.content_type.first)
      end
    end
  end
end