Sha256: d0281d0983cc236e43143615060fb8cfa94ec6f8bb4194d591d4d94aa3f8dbc5

Contents?: true

Size: 1.64 KB

Versions: 29

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

require "mime/type"

# A version of MIME::Type that works hand-in-hand with a MIME::Types::Columnar
# container to load data by columns.
#
# When a field is has not yet been loaded, that data will be loaded for all
# types in the container before forwarding the message to MIME::Type.
#
# More information can be found in MIME::Types::Columnar.
#
# MIME::Type::Columnar is *not* intended to be created except by
# MIME::Types::Columnar containers.
class MIME::Type::Columnar < MIME::Type
  def initialize(container, content_type, extensions) # :nodoc:
    @container = container
    self.content_type = content_type
    self.extensions = extensions
  end

  def self.column(*methods, file: nil) # :nodoc:
    file ||= methods.first

    file_method = :"load_#{file}"
    methods.each do |m|
      define_method m do |*args|
        @container.send(file_method)
        super(*args)
      end
    end
  end

  column :friendly
  column :encoding, :encoding=
  column :docs, :docs=
  column :preferred_extension, :preferred_extension=
  column :obsolete, :obsolete=, :obsolete?, :registered, :registered=, :registered?, :signature, :signature=,
    :signature?, :provisional, :provisional=, :provisional?, file: "flags"
  column :xrefs, :xrefs=, :xref_urls
  column :use_instead, :use_instead=

  def encode_with(coder) # :nodoc:
    @container.send(:load_friendly)
    @container.send(:load_encoding)
    @container.send(:load_docs)
    @container.send(:load_flags)
    @container.send(:load_use_instead)
    @container.send(:load_xrefs)
    @container.send(:load_preferred_extension)
    super
  end

  class << self
    undef column
  end
end

Version data entries

29 entries across 29 versions & 7 rubygems

Version Path
kinetic_sdk-5.0.29 gems/mime-types-3.6.0/lib/mime/type/columnar.rb
kinetic_sdk-5.0.28 gems/mime-types-3.6.0/lib/mime/type/columnar.rb
mime-types-3.6.0 lib/mime/type/columnar.rb
mime-types-3.6.0.beta1 lib/mime/type/columnar.rb
kinetic_sdk-5.0.27 gems/mime-types-3.5.2/lib/mime/type/columnar.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/mime-types-3.5.2/lib/mime/type/columnar.rb
kinetic_sdk-5.0.26 gems/mime-types-3.5.2/lib/mime/type/columnar.rb
kinetic_sdk-5.0.25 gems/mime-types-3.5.2/lib/mime/type/columnar.rb
kinetic_sdk-5.0.24 gems/mime-types-3.5.2/lib/mime/type/columnar.rb
kinetic_sdk-5.0.23 gems/mime-types-3.5.2/lib/mime/type/columnar.rb
mime-types-3.5.2 lib/mime/type/columnar.rb
kinetic_sdk-5.0.22 gems/mime-types-3.4.1/lib/mime/type/columnar.rb
mime-types-3.5.1 lib/mime/type/columnar.rb
mime-types-3.5.0 lib/mime/type/columnar.rb
kinetic_sdk-5.0.21 gems/mime-types-3.4.1/lib/mime/type/columnar.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb