Class: Mongoid::Persistence::Command
- Includes:
- Safe
- Defined in:
- lib/mongoid/persistence/command.rb
Overview
Persistence commands extend from this class to get basic functionality on initialization.
Direct Known Subclasses
Insert, InsertEmbedded, Remove, RemoveAll, RemoveEmbedded, Update
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
-
#suppress ⇒ Object
readonly
Returns the value of attribute suppress.
-
#validate ⇒ Object
readonly
Returns the value of attribute validate.
Instance Method Summary collapse
-
#initialize(document_or_class, options = {}, selector = {}) ⇒ Command
constructor
Initialize the persistence
Command
.
Methods included from Safe
Constructor Details
#initialize(document_or_class, options = {}, selector = {}) ⇒ Command
Initialize the persistence Command
.
Options:
document_or_class: The Document
or Class
to get the collection. options: Options like validation or safe mode. selector: Optional selector to use in query.
Example:
DeleteAll.new(Person, { :validate => true }, {})
29 30 31 32 33 34 35 36 |
# File 'lib/mongoid/persistence/command.rb', line 29 def initialize(document_or_class, = {}, selector = {}) init(document_or_class) validate = [:validate] @suppress = [:suppress] @validate = (validate.nil? ? true : validate) @selector = selector @options = { :safe => safe_mode?() } end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
9 10 11 |
# File 'lib/mongoid/persistence/command.rb', line 9 def collection @collection end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
9 10 11 |
# File 'lib/mongoid/persistence/command.rb', line 9 def document @document end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
9 10 11 |
# File 'lib/mongoid/persistence/command.rb', line 9 def klass @klass end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/mongoid/persistence/command.rb', line 9 def @options end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
9 10 11 |
# File 'lib/mongoid/persistence/command.rb', line 9 def selector @selector end |
#suppress ⇒ Object (readonly)
Returns the value of attribute suppress.
9 10 11 |
# File 'lib/mongoid/persistence/command.rb', line 9 def suppress @suppress end |
#validate ⇒ Object (readonly)
Returns the value of attribute validate.
9 10 11 |
# File 'lib/mongoid/persistence/command.rb', line 9 def validate @validate end |