File: adapter.rb

package info (click to toggle)
ruby-http 4.4.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 704 kB
  • sloc: ruby: 5,388; makefile: 9
file content (26 lines) | stat: -rw-r--r-- 548 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

require "forwardable"
require "singleton"

module HTTP
  module MimeType
    # Base encode/decode MIME type adapter
    class Adapter
      include Singleton

      class << self
        extend Forwardable
        def_delegators :instance, :encode, :decode
      end

      %w[encode decode].each do |operation|
        class_eval <<-RUBY, __FILE__, __LINE__
          def #{operation}(*)
            fail Error, "\#{self.class} does not supports ##{operation}"
          end
        RUBY
      end
    end
  end
end