Class: Kabutops::Adapters::Mongo

Inherits:
DatabaseAdapter show all
Includes:
Extensions::Parameterable
Defined in:
lib/kabutops/adapters/mongo.rb

Instance Attribute Summary

Attributes inherited from DatabaseAdapter

#recipe

Instance Method Summary collapse

Methods included from Extensions::Includable

#append_features, #included

Methods inherited from DatabaseAdapter

#data, #process

Methods included from Extensions::CallbackSupport

#callbacks, #notify

Methods included from Extensions::Logging

#logger

Methods inherited from Base

#debug, #enable_debug, #initialize

Constructor Details

This class inherits a constructor from Kabutops::Adapters::Base

Instance Method Details

#nested?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/kabutops/adapters/mongo.rb', line 24

def nested?
  true
end

#store(result) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kabutops/adapters/mongo.rb', line 12

def store result
  existing = collection.find('id' => result[:id])

  if existing.count > 0
    existing.each do |document|
      collection.update({'_id' => document['_id']}, result.to_hash)
    end
  else
    collection.insert(result.to_hash)
  end
end