module Cequel::Record::Dirty

Cequel provides support for dirty attribute tracking via ActiveModel. Modifications to collection columns are registered by this mechanism.

@see api.rubyonrails.org/classes/ActiveModel/Dirty.html Rails

documentation for ActiveModel::Dirty

@since 0.1.0

Public Instance Methods

save(options = {}) click to toggle source

@private

Calls superclass method
# File lib/cequel/record/dirty.rb, line 46
def save(options = {})
  super.tap do |success|
    if success
      if self.respond_to?(:changes_applied)
        changes_applied
      else
        @previously_changed = changes
        @changed_attributes.clear
      end
    end
  end
end

Private Instance Methods

write_attribute(name, value) click to toggle source
Calls superclass method
# File lib/cequel/record/dirty.rb, line 61
def write_attribute(name, value)
  column = self.class.reflect_on_column(name)
  fail UnknownAttributeError, "unknown attribute: #{name}" unless column
  value = column.cast(value) unless value.nil?

  if loaded? && value != read_attribute(name)
    __send__("#{name}_will_change!")
  end
  super
end