Sha256: bb1833e229f7b516831eec3d2f63bea0b16ec7a3b897713aa556f352665d30bf

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

##
# Outpost::Model::Methods
#
# This could be renamed to something more specific
module Outpost
  module Model
    module Methods
      extend ActiveSupport::Concern
      
      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
    end # Methods
  end # Model
end # Outpost

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-cms-0.0.3 lib/outpost/model/methods.rb