Class: Mongoid::Persistence::Command

Inherits:
Object
  • Object
show all
Includes:
Safe
Defined in:
lib/mongoid/persistence/command.rb

Overview

Persistence commands extend from this class to get basic functionality on initialization.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Safe

#safe_mode?

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, options = {}, selector = {})
  init(document_or_class)
  validate = options[:validate]
  @suppress = options[:suppress]
  @validate = (validate.nil? ? true : validate)
  @selector = selector
  @options = { :safe => safe_mode?(options) }
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



9
10
11
# File 'lib/mongoid/persistence/command.rb', line 9

def collection
  @collection
end

#documentObject (readonly)

Returns the value of attribute document.



9
10
11
# File 'lib/mongoid/persistence/command.rb', line 9

def document
  @document
end

#klassObject (readonly)

Returns the value of attribute klass.



9
10
11
# File 'lib/mongoid/persistence/command.rb', line 9

def klass
  @klass
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/mongoid/persistence/command.rb', line 9

def options
  @options
end

#selectorObject (readonly)

Returns the value of attribute selector.



9
10
11
# File 'lib/mongoid/persistence/command.rb', line 9

def selector
  @selector
end

#suppressObject (readonly)

Returns the value of attribute suppress.



9
10
11
# File 'lib/mongoid/persistence/command.rb', line 9

def suppress
  @suppress
end

#validateObject (readonly)

Returns the value of attribute validate.



9
10
11
# File 'lib/mongoid/persistence/command.rb', line 9

def validate
  @validate
end