module Outpost::Model::Methods

Public Instance Methods

persisted_record() click to toggle source
# File lib/outpost/model/methods.rb, line 10
def persisted_record
  @persisted_record ||= begin
    # If this record isn't persisted, return nil
    return nil if !self.persisted?

    # If attributes have been changed, then fetch
    # the persisted record from the database
    # Otherwise just use self
    self.changed? ? self.class.find(self.id) : self
  end
end