module Disposable::Twin::Persisted

Keeps the persisted? property synced with the model’s.

Public Class Methods

included(includer) click to toggle source
# File lib/disposable/twin/persisted.rb, line 3
def self.included(includer)
  includer.send(:property, :persisted?, writeable: false)
end

Public Instance Methods

created?() click to toggle source
# File lib/disposable/twin/persisted.rb, line 13
def created?
  # when the persisted field got flipped, this means creation!
  changed?(:persisted?)
end
save!(*) click to toggle source
Calls superclass method
# File lib/disposable/twin/persisted.rb, line 7
def save!(*)
  super.tap do
    send "persisted?=", model.persisted?
  end
end