Class: Moped::PromiscuousCollectionWrapper

Inherits:
Collection
  • Object
show all
Defined in:
lib/promiscuous/publisher/operation/mongoid.rb

Defined Under Namespace

Classes: PromiscuousCollectionOperation

Instance Method Summary collapse

Instance Method Details

#insert(documents, flags = nil) ⇒ Object

Create has its own Operation class, as it’s the only scenario where there is no matching document in the database



65
66
67
68
69
70
# File 'lib/promiscuous/publisher/operation/mongoid.rb', line 65

def insert(documents, flags=nil)
  documents = [documents] unless documents.is_a?(Array)
  documents.each do |doc|
    promiscuous_create_operation(:document => doc).execute { super(doc, flags) }
  end
end

#promiscuous_create_operation(options) ⇒ Object



57
58
59
# File 'lib/promiscuous/publisher/operation/mongoid.rb', line 57

def promiscuous_create_operation(options)
  PromiscuousCollectionOperation.new(options.merge(:collection => self, :operation => :create))
end