Sha256: 820803bcc5069d2d03b3fa0b0ab2576d1fe092bc25c567d4ec165b92cce4b14a

Contents?: true

Size: 929 Bytes

Versions: 21

Compression:

Stored size: 929 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module State #:nodoc:
    # Returns true if the +Document+ has not been persisted to the database,
    # false if it has. This is determined by the variable @new_record
    # and NOT if the object has an id.
    def new_record?
      @new_record == true
    end

    # Sets the new_record boolean - used after document is saved.
    def new_record=(saved)
      @new_record = saved
    end

    # Checks if the document has been saved to the database.
    def persisted?
      !new_record?
    end

    # Returns true if the +Document+ has been succesfully destroyed, and false if it hasn't.
    # This is determined by the variable @destroyed and NOT by checking the database.
    def destroyed?
      @destroyed == true
    end

    # Sets the destroyed boolean - used after document is destroyed.
    def destroyed=(destroyed)
      @destroyed = destroyed && true
    end
  end
end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
mongoid-2.0.0.beta.20 lib/mongoid/state.rb
mongoid-2.0.0.beta.19 lib/mongoid/state.rb
mongoid-2.0.0.beta.18 lib/mongoid/state.rb
mongoid-2.0.0.beta.17 lib/mongoid/state.rb
mongoid-2.0.0.beta.16 lib/mongoid/state.rb
mongoid-2.0.0.beta.15 lib/mongoid/state.rb
mongoid-2.0.0.beta.14 lib/mongoid/state.rb
mongoid-2.0.0.beta.13 lib/mongoid/state.rb
mongoid-2.0.0.beta.11 lib/mongoid/state.rb
mongoid-2.0.0.beta.10 lib/mongoid/state.rb
mongoid-2.0.0.beta.7 lib/mongoid/state.rb
mongoid-2.0.0.beta.8 lib/mongoid/state.rb
mongoid-2.0.0.beta.9 lib/mongoid/state.rb
mongoid-2.0.0.beta.12 lib/mongoid/state.rb
mongoid-locomotive-2.0.0.beta9 lib/mongoid/state.rb
chhean-mongoid-2.0.1.beta1 lib/mongoid/state.rb
mongoid-2.0.0.beta.5 lib/mongoid/state.rb
mongoid-pre-2.0.0.beta1 lib/mongoid/state.rb
mongoid-2.0.0.alpha lib/mongoid/state.rb
mongoid-1.2.14 lib/mongoid/state.rb