Module: Outpost::Model::Methods

Extended by:
ActiveSupport::Concern
Defined in:
lib/outpost/model/methods.rb

Instance Method Summary collapse

Instance Method Details

#persisted_recordObject



10
11
12
13
14
15
16
17
18
19
20
# 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