Module: MIME::Types::Columnar

Defined in:
lib/mime/types/_columnar.rb

Overview

MIME::Types::Columnar is used to extend a MIME::Types container to load data by columns instead of from JSON or YAML. Column loads of MIME types loaded through the columnar store are synchronized with a Mutex.

MIME::Types::Columnar is not intended to be used directly, but will be added to an instance of MIME::Types when it is loaded with MIME::Types::Loader#load_columnar.

Constant Summary collapse

LOAD_MUTEX =

:nodoc:

Mutex.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(obj) ⇒ Object

:nodoc:


15
16
17
18
19
# File 'lib/mime/types/_columnar.rb', line 15

def self.extended(obj) # :nodoc:
  super
  obj.instance_variable_set(:@__mime_data__, [])
  obj.instance_variable_set(:@__files__, Set.new)
end

Instance Method Details

#load_base_data(path) ⇒ Object

Load the first column data file (type and extensions).


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mime/types/_columnar.rb', line 22

def load_base_data(path) #:nodoc:
  @__root__ = path

  each_file_line('content_type', false) do |line|
    line = line.split
    content_type = line.shift
    extensions = line
    # content_type, *extensions = line.split

    type = MIME::Type::Columnar.new(self, content_type, extensions)
    @__mime_data__ << type
    add(type)
  end

  self
end