Class: Columbo::DbClient

Inherits:
Object
  • Object
show all
Includes:
Mongo
Defined in:
lib/columbo/db_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ DbClient

Returns a new instance of DbClient.



9
10
11
12
13
# File 'lib/columbo/db_client.rb', line 9

def initialize(uri)
  client = Mongo::MongoClient.from_uri(uri)
  db = client[uri.split('/').last]
  @coll  = db[Columbo::MONGO_COLLECTION]
end

Instance Attribute Details

#collObject

Returns the value of attribute coll.



7
8
9
# File 'lib/columbo/db_client.rb', line 7

def coll
  @coll
end

Instance Method Details

#find(*args) ⇒ Object



23
24
25
# File 'lib/columbo/db_client.rb', line 23

def find(*args)
  coll.find *args
end

#find_one(*args) ⇒ Object



27
28
29
# File 'lib/columbo/db_client.rb', line 27

def find_one(*args)
  coll.find_one *args
end

#insert(*args) ⇒ Object



15
16
17
# File 'lib/columbo/db_client.rb', line 15

def insert(*args)
  coll.insert *args
end

#remove(*args) ⇒ Object



31
32
33
# File 'lib/columbo/db_client.rb', line 31

def remove(*args)
  coll.remove *args
end

#save(*args) ⇒ Object



19
20
21
# File 'lib/columbo/db_client.rb', line 19

def save(*args)
  coll.save *args
end

#update(*args) ⇒ Object



35
36
37
# File 'lib/columbo/db_client.rb', line 35

def update(*args)
  coll.update *args
end