Method: Sequel::Model::InstanceMethods#modified?

Defined in:
lib/sequel/model/base.rb

#modified?(column = nil) ⇒ Boolean

Whether this object has been modified since last saved, used by save_changes to determine whether changes should be saved. New values are always considered modified.

a = Artist[1]
a.modified? # => false
a.set(:name=>'Jim')
a.modified? # => true

If a column is given, specifically check if the given column has been modified:

a.modified?(:num_albums) # => false
a.num_albums = 10
a.modified?(:num_albums) # => true

Returns:

  • (Boolean)


1577
1578
1579
1580
1581
1582
1583
# File 'lib/sequel/model/base.rb', line 1577

def modified?(column=nil)
  if column
    changed_columns.include?(column)
  else
    @modified || !changed_columns.empty?
  end
end