Module: Mongoid::State
- Defined in:
- lib/mongoid/state.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#destroyed=(destroyed) ⇒ Object
Sets the destroyed boolean - used after document is destroyed.
-
#destroyed? ⇒ Boolean
Returns true if the
Document
has been succesfully destroyed, and false if it hasn’t. -
#new_record=(saved) ⇒ Object
Sets the new_record boolean - used after document is saved.
-
#new_record? ⇒ Boolean
Returns true if the
Document
has not been persisted to the database, false if it has. -
#persisted? ⇒ Boolean
Checks if the document has been saved to the database.
Instance Method Details
#destroyed=(destroyed) ⇒ Object
Sets the destroyed boolean - used after document is destroyed.
28 29 30 |
# File 'lib/mongoid/state.rb', line 28 def destroyed=(destroyed) @destroyed = destroyed && true end |
#destroyed? ⇒ Boolean
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.
23 24 25 |
# File 'lib/mongoid/state.rb', line 23 def destroyed? @destroyed == true end |
#new_record=(saved) ⇒ Object
Sets the new_record boolean - used after document is saved.
12 13 14 |
# File 'lib/mongoid/state.rb', line 12 def new_record=(saved) @new_record = saved end |
#new_record? ⇒ Boolean
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.
7 8 9 |
# File 'lib/mongoid/state.rb', line 7 def new_record? @new_record == true end |
#persisted? ⇒ Boolean
Checks if the document has been saved to the database.
17 18 19 |
# File 'lib/mongoid/state.rb', line 17 def persisted? !new_record? end |