mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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>
This commit is contained in:
parent
3ae8d6d67c
commit
dd0040d19f
1 changed files with 15 additions and 10 deletions
|
@ -288,7 +288,12 @@ module Mime
|
|||
@@html_types.include?(to_sym) || @string =~ /html/
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue