@@ -22,7 +22,7 @@ def #{method}(*)
22
22
23
23
SET = Mimes . new
24
24
EXTENSION_LOOKUP = { }
25
- LOOKUP = Hash . new { | h , k | h [ k ] = Type . new ( k ) unless k . blank? }
25
+ LOOKUP = { }
26
26
27
27
def self . []( type )
28
28
return type if type . is_a? ( Type )
@@ -85,7 +85,7 @@ class << self
85
85
Q_SEPARATOR_REGEXP = /;\s *q=/
86
86
87
87
def lookup ( string )
88
- LOOKUP [ string ]
88
+ LOOKUP [ string ] || Type . new ( string )
89
89
end
90
90
91
91
def lookup_by_extension ( extension )
@@ -204,9 +204,12 @@ def unregister(symbol)
204
204
end
205
205
end
206
206
207
+ attr_reader :hash
208
+
207
209
def initialize ( string , symbol = nil , synonyms = [ ] )
208
210
@symbol , @synonyms = symbol , synonyms
209
211
@string = string
212
+ @hash = [ @string , @synonyms , @symbol ] . hash
210
213
end
211
214
212
215
def to_s
@@ -240,6 +243,13 @@ def ==(mime_type)
240
243
end
241
244
end
242
245
246
+ def eql? ( other )
247
+ super || ( self . class == other . class &&
248
+ @string == other . string &&
249
+ @synonyms == other . synonyms &&
250
+ @symbol == other . symbol )
251
+ end
252
+
243
253
def =~( mime_type )
244
254
return false if mime_type . blank?
245
255
regexp = Regexp . new ( Regexp . quote ( mime_type . to_s ) )
@@ -262,6 +272,10 @@ def respond_to?(method, include_private = false) #:nodoc:
262
272
super || method . to_s =~ /(\w +)\? $/
263
273
end
264
274
275
+ protected
276
+
277
+ attr_reader :string , :synonyms
278
+
265
279
private
266
280
def method_missing ( method , *args )
267
281
if method . to_s =~ /(\w +)\? $/
0 commit comments