Convert Mime::NullType in a singleton
This commit is contained in:
parent
66b1c2d3b5
commit
abc1e5831c
@ -1,4 +1,5 @@
|
|||||||
require 'set'
|
require 'set'
|
||||||
|
require 'singleton'
|
||||||
require 'active_support/core_ext/module/attribute_accessors'
|
require 'active_support/core_ext/module/attribute_accessors'
|
||||||
require 'active_support/core_ext/string/starts_ends_with'
|
require 'active_support/core_ext/string/starts_ends_with'
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ def #{method}(*)
|
|||||||
class << self
|
class << self
|
||||||
def [](type)
|
def [](type)
|
||||||
return type if type.is_a?(Type)
|
return type if type.is_a?(Type)
|
||||||
Type.lookup_by_extension(type) || NullType.new
|
Type.lookup_by_extension(type) || NullType.instance
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch(type)
|
def fetch(type)
|
||||||
@ -292,6 +293,8 @@ def respond_to_missing?(method, include_private = false) #:nodoc:
|
|||||||
end
|
end
|
||||||
|
|
||||||
class NullType
|
class NullType
|
||||||
|
include Singleton
|
||||||
|
|
||||||
def nil?
|
def nil?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user