module ActiveModel::Dirty

Private Instance Methods

attribute_changed_with_specification?(attr, *args) click to toggle source
# File lib/active_model/attribute_changed_specification/specification.rb, line 7
def attribute_changed_with_specification?(attr, *args)
  if args.empty?
    attribute_changed_without_specification?(attr)
  else
    return false unless self.changes.include?(attr)
    from = args[0][:from]
    to   = args[0][:to]

    if from && to
      self.changes[attr][0] == from && __send__(attr) == to
    elsif from
      self.changes[attr][0] == from
    elsif to
      __send__(attr) == to
    else
      attribute_changed_without_specification?(attr, args)
    end
  end
end