mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update comment in attribute_method_matchers_matching
The current comment here is from 2011 and its original context has changed completely. The plain matcher will not "match every time" anymore since the code now filters all matchers, and only selects those for which the captured attribute is valid. To avoid confusion, I updated the comment. For more discussion, see: https://github.com/rails/rails/pull/36005
This commit is contained in:
parent
afc17e5ea2
commit
14ff93c4bc
1 changed files with 3 additions and 2 deletions
|
@ -352,8 +352,9 @@ module ActiveModel
|
|||
|
||||
def attribute_method_matchers_matching(method_name)
|
||||
attribute_method_matchers_cache.compute_if_absent(method_name) do
|
||||
# Must try to match prefixes/suffixes first, or else the matcher with no prefix/suffix
|
||||
# will match every time.
|
||||
# Bump plain matcher to last place so that only methods that do not
|
||||
# match any other pattern match the actual attribute name.
|
||||
# This is currently only needed to support legacy usage.
|
||||
matchers = attribute_method_matchers.partition(&:plain?).reverse.flatten(1)
|
||||
matchers.map { |matcher| matcher.match(method_name) }.compact
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue