mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #24511 from lihanli/activemodel-dirty-attribute-changed
speed up ActiveModel::Dirty#attribute_changed?
This commit is contained in:
commit
20ffb63c2e
1 changed files with 5 additions and 3 deletions
|
@ -174,10 +174,12 @@ module ActiveModel
|
|||
end
|
||||
|
||||
# Handles <tt>*_changed?</tt> for +method_missing+.
|
||||
def attribute_changed?(attr, options = {}) #:nodoc:
|
||||
def attribute_changed?(attr, options = nil) #:nodoc:
|
||||
result = changes_include?(attr)
|
||||
result &&= options[:to] == __send__(attr) if options.key?(:to)
|
||||
result &&= options[:from] == changed_attributes[attr] if options.key?(:from)
|
||||
if options
|
||||
result &&= options[:to] == __send__(attr) if options.key?(:to)
|
||||
result &&= options[:from] == changed_attributes[attr] if options.key?(:from)
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue