diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-11-23 23:28:57 +0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-11-25 04:38:47 +0800 |
commit | e8708836252852d8bae87c80472b865812fa9776 (patch) | |
tree | 0ea7dd6319d9a9d284533d1c01776a9ba968be31 /actionpack/lib/action_dispatch/http/mime_type.rb | |
parent | c6030e8562cddcb71898a1dea242affe5f0464f0 (diff) | |
download | rails-e8708836252852d8bae87c80472b865812fa9776.tar.gz rails-e8708836252852d8bae87c80472b865812fa9776.tar.bz2 rails-e8708836252852d8bae87c80472b865812fa9776.zip |
unregister method implementation and test
Diffstat (limited to 'actionpack/lib/action_dispatch/http/mime_type.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_type.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index 2250cfa88a..2b8395fc09 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -177,6 +177,18 @@ module Mime keys = Mime::LOOKUP.keys.select{|k| k.include?(input)} Mime::LOOKUP.values_at(*keys).uniq end + + # This method is opposite of register method. + # + # Usage: + # + # Mime::Type.unregister("text/x-mobile", :mobile) + def unregister(string, symbol) + EXTENSION_LOOKUP.delete(symbol.to_s) + LOOKUP.delete(string) + symbol = symbol.to_s.upcase.intern + Mime.module_eval { remove_const(symbol) if const_defined?(symbol) } + end end def initialize(string, symbol = nil, synonyms = []) |