Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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>
  • Loading branch information...
commit dd0040d19f2b161201fd54e21fc807fb987f016d 1 parent 3ae8d6d
@tenderlove tenderlove authored
Showing with 14 additions and 9 deletions.
  1. +14 −9 actionpack/lib/action_dispatch/http/mime_type.rb
View
23 actionpack/lib/action_dispatch/http/mime_type.rb
@@ -288,18 +288,23 @@ def html?
@@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
Please sign in to comment.
Something went wrong with that request. Please try again.