aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/mime_type.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-11-09 14:28:22 +0900
committerAaron Patterson <aaron.patterson@gmail.com>2012-11-09 14:28:22 +0900
commitdd0040d19f2b161201fd54e21fc807fb987f016d (patch)
tree56704b21f5c8f574c320a3b8b5512ebb6e71f1ac /actionpack/lib/action_dispatch/http/mime_type.rb
parent3ae8d6d67cd86213c2e48d5471cf2634abc13bb3 (diff)
downloadrails-dd0040d19f2b161201fd54e21fc807fb987f016d.tar.gz
rails-dd0040d19f2b161201fd54e21fc807fb987f016d.tar.bz2
rails-dd0040d19f2b161201fd54e21fc807fb987f016d.zip
implement to_a and to_ary so that the Array() call in template.rb will
not raise so many exceptions: https://github.com/rails/rails/blob/master/actionpack/lib/action_view/template.rb#L126 irb(main):001:0> class Foo; def method_missing(*args); super; end end => nil irb(main):002:0> $DEBUG = true => true irb(main):003:0> Array(Foo.new) Exception `NoMethodError' at (irb):1 - undefined method `to_ary' for #<Foo:0x007f854390e488> Exception `NoMethodError' at (irb):1 - undefined method `to_a' for #<Foo:0x007f854390e488> => [#<Foo:0x007f854390e488>] irb(main):004:0>
Diffstat (limited to 'actionpack/lib/action_dispatch/http/mime_type.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index 2b5d3d85bf..f56f09c5b3 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -288,18 +288,23 @@ module Mime
@@html_types.include?(to_sym) || @string =~ /html/
end
+
private
- def method_missing(method, *args)
- if method.to_s.ends_with? '?'
- method[0..-2].downcase.to_sym == to_sym
- else
- super
- end
- end
- def respond_to_missing?(method, include_private = false) #:nodoc:
- method.to_s.ends_with? '?'
+ def to_ary; end
+ def to_a; end
+
+ def method_missing(method, *args)
+ if method.to_s.ends_with? '?'
+ method[0..-2].downcase.to_sym == to_sym
+ else
+ super
end
+ end
+
+ def respond_to_missing?(method, include_private = false) #:nodoc:
+ method.to_s.ends_with? '?'
+ end
end
end