mongo_adaptor 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongo_adaptor.rb +4 -4
- data/lib/mongo_adaptor/version.rb +1 -1
- data/spec/mongo_adaptor_spec.rb +5 -7
- metadata +4 -4
data/lib/mongo_adaptor.rb
CHANGED
@@ -35,16 +35,16 @@ class MongoAdaptor
|
|
35
35
|
@collection.update query, command, safe_mode.merge(upsert_mode false).merge(options)
|
36
36
|
end
|
37
37
|
|
38
|
-
def fetch selector = {}, opts = {
|
39
|
-
@collection.find_one selector,
|
38
|
+
def fetch selector = {}, opts = {}
|
39
|
+
@collection.find_one selector, { :fields => fields, :transformer => builder }.merge(opts)
|
40
40
|
end
|
41
41
|
|
42
42
|
def remove selector = {}, opts = {}
|
43
43
|
@collection.remove selector, opts
|
44
44
|
end
|
45
45
|
|
46
|
-
def find selector = {}, opts = {
|
47
|
-
@collection.find selector,
|
46
|
+
def find selector = {}, opts = {}
|
47
|
+
@collection.find selector, { :fields => fields, :transformer => builder }.merge(opts)
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
data/spec/mongo_adaptor_spec.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
require 'mongo_adaptor'
|
2
2
|
|
3
3
|
describe 'adapting structs into mongo' do
|
4
|
-
before
|
5
|
-
|
6
|
-
end
|
7
|
-
after do
|
8
|
-
Mongo::Configure.current.load.collections.select { |c| c.name !~ /^system\./ }.each &:remove
|
9
|
-
end
|
4
|
+
before { Mongo::Configure.from_database 'mongo_adaptor_test' }
|
5
|
+
after { Mongo::Configure.current.load.collections.select { |c| c.name !~ /^system\./ }.each &:remove }
|
10
6
|
|
11
7
|
describe 'db setup' do
|
12
8
|
it 'uses the configured database' do
|
@@ -47,12 +43,14 @@ describe 'adapting structs into mongo' do
|
|
47
43
|
subject { adaptor.insert model }
|
48
44
|
it_should_behave_like 'new model'
|
49
45
|
end
|
46
|
+
|
50
47
|
context 'upserting' do
|
51
48
|
subject { adaptor.upsert model, {} }
|
52
49
|
it_should_behave_like 'new model'
|
53
50
|
end
|
51
|
+
|
54
52
|
describe 'upserting with a custom operation' do
|
55
|
-
subject { adaptor.execute({ name
|
53
|
+
subject { adaptor.execute({ :name => 'value' }, { '$push' => { "key" => "value" } }, { :upsert => true }) }
|
56
54
|
it_should_behave_like 'creates a document'
|
57
55
|
it 'will execute my command' do
|
58
56
|
subject
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_adaptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongo
|
@@ -122,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
segments:
|
124
124
|
- 0
|
125
|
-
hash:
|
125
|
+
hash: 1930400006720958320
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
segments:
|
133
133
|
- 0
|
134
|
-
hash:
|
134
|
+
hash: 1930400006720958320
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
137
|
rubygems_version: 1.8.25
|