aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-09-21 14:10:17 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-09-21 14:10:17 -0700
commitf8ba48c150fb70ed0bcb8ff74cf2aabc81173082 (patch)
treeada3ef19522f883e7de3a8a094456fb2c2feb134 /actionpack/lib/action_dispatch
parent7cdb2ec9636288dce25836c3ec0f261537a6425f (diff)
downloadrails-f8ba48c150fb70ed0bcb8ff74cf2aabc81173082.tar.gz
rails-f8ba48c150fb70ed0bcb8ff74cf2aabc81173082.tar.bz2
rails-f8ba48c150fb70ed0bcb8ff74cf2aabc81173082.zip
introduce an `All` mime type
This class gives us the `all?` predicate method that returns true without hitting method missing
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb6
-rw-r--r--actionpack/lib/action_dispatch/http/mime_types.rb2
2 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index 2d49ad661c..553f19b5bc 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -331,6 +331,7 @@ to:
@@html_types.include?(to_sym) || @string =~ /html/
end
+ def all?; false; end
private
@@ -348,6 +349,11 @@ to:
def respond_to_missing?(method, include_private = false) #:nodoc:
method.to_s.ends_with? '?'
end
+
+ class All < Type
+ def all?; true; end
+ def html?; true; end
+ end
end
class NullType
diff --git a/actionpack/lib/action_dispatch/http/mime_types.rb b/actionpack/lib/action_dispatch/http/mime_types.rb
index d349cf2807..0af3e5c0df 100644
--- a/actionpack/lib/action_dispatch/http/mime_types.rb
+++ b/actionpack/lib/action_dispatch/http/mime_types.rb
@@ -33,4 +33,4 @@ Mime::Type.register "application/pdf", :pdf, [], %w(pdf)
Mime::Type.register "application/zip", :zip, [], %w(zip)
# Create Mime::ALL but do not add it to the SET.
-Mime::Type.add_type :ALL, Mime::Type.new("*/*", :all, [])
+Mime::Type.add_type :ALL, Mime::Type::All.new("*/*", :all, [])