提交 d5fbb04f 编写于 作者: A Akira Matsuda

AS::ArrayInquirer#respond_to_missing? should fallback to super

in case Array or any other ancestor class' respond_to_missing? was defined.
上级 c0c331bf
* Fixed a bug that `ArrayInquirer#respond_to_missing?` does not fallback to
`Array#respond_to_missing?`.
*Akira Matsuda*
* Fix inconsistent results when parsing large durations and constructing durations from code
ActiveSupport::Duration.parse('P3Y') == 3.years # It should be true
......
......@@ -32,7 +32,7 @@ def any?(*candidates, &block)
private
def respond_to_missing?(name, include_private = false)
name[-1] == "?"
(name[-1] == "?") || super
end
def method_missing(name, *args)
......
......@@ -38,4 +38,18 @@ def test_inquiry
assert_instance_of ActiveSupport::ArrayInquirer, result
assert_equal @array_inquirer, result
end
def test_respond_to_fallback_to_array_respond_to
arr = ActiveSupport::ArrayInquirer.new([:x])
# This kind of emulates a situation that Array#respond_to_missing? is defined
arr.singleton_class.class_eval do
def respond_to_missing?(name, _include_private = false)
(name == :foo) || super
end
end
assert_respond_to arr, :can_you_hear_me?
assert_respond_to arr, :foo
assert_not_respond_to arr, :nope
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册