File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
actionpack/lib/action_dispatch/http Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ def #{method}(*)
23
23
24
24
SET = Mimes . new
25
25
EXTENSION_LOOKUP = { }
26
- LOOKUP = Hash . new { | h , k | h [ k ] = Type . new ( k ) unless k . blank? }
26
+ LOOKUP = { }
27
27
28
28
class << self
29
29
def []( type )
@@ -146,7 +146,7 @@ def register_callback(&block)
146
146
end
147
147
148
148
def lookup ( string )
149
- LOOKUP [ string ]
149
+ LOOKUP [ string ] || Type . new ( string )
150
150
end
151
151
152
152
def lookup_by_extension ( extension )
@@ -225,9 +225,12 @@ def unregister(symbol)
225
225
end
226
226
end
227
227
228
+ attr_reader :hash
229
+
228
230
def initialize ( string , symbol = nil , synonyms = [ ] )
229
231
@symbol , @synonyms = symbol , synonyms
230
232
@string = string
233
+ @hash = [ @string , @synonyms , @symbol ] . hash
231
234
end
232
235
233
236
def to_s
@@ -261,6 +264,13 @@ def ==(mime_type)
261
264
end
262
265
end
263
266
267
+ def eql? ( other )
268
+ super || ( self . class == other . class &&
269
+ @string == other . string &&
270
+ @synonyms == other . synonyms &&
271
+ @symbol == other . symbol )
272
+ end
273
+
264
274
def =~( mime_type )
265
275
return false if mime_type . blank?
266
276
regexp = Regexp . new ( Regexp . quote ( mime_type . to_s ) )
@@ -274,6 +284,10 @@ def html?
274
284
end
275
285
276
286
287
+ protected
288
+
289
+ attr_reader :string , :synonyms
290
+
277
291
private
278
292
279
293
def to_ary ; end
You can’t perform that action at this time.
0 commit comments