Permalink
Browse files

Convert Mime::NullType in a singleton

  • Loading branch information...
1 parent 66b1c2d commit abc1e5831cae724cfcdf524f62abb71be02d7e86 @guilleiguaran guilleiguaran committed Dec 3, 2013
Showing with 4 additions and 1 deletion.
  1. +4 −1 actionpack/lib/action_dispatch/http/mime_type.rb
@@ -1,4 +1,5 @@
require 'set'
+require 'singleton'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/string/starts_ends_with'
@@ -27,7 +28,7 @@ def #{method}(*)
class << self
def [](type)
return type if type.is_a?(Type)
- Type.lookup_by_extension(type) || NullType.new
+ Type.lookup_by_extension(type) || NullType.instance
end
def fetch(type)
@@ -292,6 +293,8 @@ def respond_to_missing?(method, include_private = false) #:nodoc:
end
class NullType
+ include Singleton
+
def nil?
true
end

0 comments on commit abc1e58

Please sign in to comment.