Sha256: f9d5b6d74835e9202ffe0c7c021a385f28b0728b116ea30e7956c1e36f34423b

Contents?: true

Size: 597 Bytes

Versions: 7

Compression:

Stored size: 597 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

7 entries across 7 versions & 1 rubygems

Version Path
outpost-cms-0.1.4 lib/outpost/model/methods.rb
outpost-cms-0.1.3 lib/outpost/model/methods.rb
outpost-cms-0.1.2 lib/outpost/model/methods.rb
outpost-cms-0.1.1 lib/outpost/model/methods.rb
outpost-cms-0.1.0 lib/outpost/model/methods.rb
outpost-cms-0.0.5 lib/outpost/model/methods.rb
outpost-cms-0.0.4 lib/outpost/model/methods.rb