mongo_mapper 0.15.3 → 0.15.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -6
- data/lib/mongo_mapper/connection.rb +1 -1
- data/lib/mongo_mapper/document.rb +1 -0
- data/lib/mongo_mapper/extensions/array.rb +1 -1
- data/lib/mongo_mapper/extensions/binary.rb +1 -1
- data/lib/mongo_mapper/extensions/date.rb +1 -1
- data/lib/mongo_mapper/extensions/float.rb +1 -1
- data/lib/mongo_mapper/extensions/hash.rb +1 -1
- data/lib/mongo_mapper/extensions/nil_class.rb +2 -2
- data/lib/mongo_mapper/extensions/object.rb +1 -1
- data/lib/mongo_mapper/extensions/object_id.rb +1 -1
- data/lib/mongo_mapper/extensions/set.rb +1 -1
- data/lib/mongo_mapper/extensions/string.rb +1 -1
- data/lib/mongo_mapper/plugins/associations/many_association.rb +2 -3
- data/lib/mongo_mapper/plugins/associations/{belongs_to_polymorphic_proxy.rb → proxy/belongs_to_polymorphic_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{belongs_to_proxy.rb → proxy/belongs_to_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/proxy/collection.rb +55 -0
- data/lib/mongo_mapper/plugins/associations/{embedded_collection.rb → proxy/embedded_collection.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{in_array_proxy.rb → proxy/in_array_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{in_foreign_array_proxy.rb → proxy/in_foreign_array_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{many_documents_as_proxy.rb → proxy/many_documents_as_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{many_documents_proxy.rb → proxy/many_documents_proxy.rb} +0 -4
- data/lib/mongo_mapper/plugins/associations/{many_embedded_polymorphic_proxy.rb → proxy/many_embedded_polymorphic_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{many_embedded_proxy.rb → proxy/many_embedded_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{many_polymorphic_proxy.rb → proxy/many_polymorphic_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{one_as_proxy.rb → proxy/one_as_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{one_embedded_polymorphic_proxy.rb → proxy/one_embedded_polymorphic_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{one_embedded_proxy.rb → proxy/one_embedded_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{one_proxy.rb → proxy/one_proxy.rb} +0 -0
- data/lib/mongo_mapper/plugins/associations/{proxy.rb → proxy/proxy.rb} +64 -48
- data/lib/mongo_mapper/plugins/associations/single_association.rb +2 -11
- data/lib/mongo_mapper/plugins/caching.rb +2 -2
- data/lib/mongo_mapper/plugins/dirty.rb +1 -1
- data/lib/mongo_mapper/plugins/embedded_callbacks.rb +2 -2
- data/lib/mongo_mapper/plugins/keys/key.rb +9 -6
- data/lib/mongo_mapper/plugins/keys.rb +14 -2
- data/lib/mongo_mapper/plugins/querying.rb +2 -2
- data/lib/mongo_mapper/plugins/shardable.rb +30 -0
- data/lib/mongo_mapper/plugins/validations.rb +1 -1
- data/lib/mongo_mapper/plugins.rb +18 -1
- data/lib/mongo_mapper/version.rb +1 -1
- data/lib/mongo_mapper.rb +18 -18
- data/spec/examples.txt +1711 -1701
- data/spec/functional/callbacks_spec.rb +5 -1
- data/spec/functional/keys_spec.rb +13 -0
- data/spec/functional/shardable_spec.rb +59 -0
- data/spec/support/sharded_model.rb +24 -0
- data/spec/unit/associations/proxy_spec.rb +18 -5
- data/spec/unit/document_spec.rb +1 -1
- data/spec/unit/embedded_document_spec.rb +3 -3
- data/spec/unit/extensions_spec.rb +9 -3
- data/spec/unit/inspect_spec.rb +1 -1
- data/spec/unit/key_spec.rb +7 -1
- data/spec/unit/mongo_mapper_spec.rb +10 -5
- metadata +36 -19
- data/lib/mongo_mapper/plugins/associations/collection.rb +0 -29
@@ -10,10 +10,14 @@ module CallbacksSupport
|
|
10
10
|
:before_save, :after_save,
|
11
11
|
:before_destroy, :after_destroy
|
12
12
|
].each do |callback|
|
13
|
-
base.send(callback) do
|
13
|
+
base.send(callback, if: :always_true) do
|
14
14
|
history << callback.to_sym
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
base.send(:define_method, :always_true) do
|
19
|
+
true
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def history
|
@@ -352,6 +352,19 @@ describe "Keys" do
|
|
352
352
|
it 'should remove the key' do
|
353
353
|
DocWithRemovedKey.keys.should_not have_key "_something"
|
354
354
|
end
|
355
|
+
end
|
356
|
+
|
357
|
+
describe "default with no type" do
|
358
|
+
it "should work (regression)" do
|
359
|
+
doc = Doc do
|
360
|
+
key :a_num, default: 0
|
361
|
+
end
|
355
362
|
|
363
|
+
instance = doc.new
|
364
|
+
instance.a_num.should == 0
|
365
|
+
|
366
|
+
instance = doc.new(a_num: 10)
|
367
|
+
instance.a_num.should == 10
|
368
|
+
end
|
356
369
|
end
|
357
370
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Shardable' do
|
4
|
+
describe 'shard_key_fields' do
|
5
|
+
it 'returns declared field names' do
|
6
|
+
ShardedModel.shard_key_fields.should == ['first_name']
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'shard_key_filter' do
|
11
|
+
context 'new record' do
|
12
|
+
let(:document) { ShardedModel.new(first_name: 'John', last_name: 'Smith') }
|
13
|
+
|
14
|
+
it 'returns current values' do
|
15
|
+
document.shard_key_filter.should == { 'first_name' => 'John' }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'persisted record' do
|
20
|
+
let(:document) { ShardedModel.create!(first_name: 'John', last_name: 'Smith') }
|
21
|
+
|
22
|
+
before do
|
23
|
+
document.first_name = 'William'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns persisted values' do
|
27
|
+
document.shard_key_filter.should == { 'first_name' => 'John' }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'creating new document' do
|
33
|
+
let(:document) { ShardedModel.new(first_name: 'John', last_name: 'Smith') }
|
34
|
+
|
35
|
+
it 'inserts new document' do
|
36
|
+
lambda { document.save! }.should change { ShardedModel.count }.by(1)
|
37
|
+
|
38
|
+
persisted = ShardedModel.find(document.id)
|
39
|
+
persisted.first_name.should == 'John'
|
40
|
+
persisted.last_name.should == 'Smith'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'updating persisted document' do
|
45
|
+
let(:document) { ShardedModel.create!(first_name: 'John', last_name: 'Smith') }
|
46
|
+
|
47
|
+
before do
|
48
|
+
document.first_name = 'William'
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'updates persisted document' do
|
52
|
+
lambda { document.save! }.should_not change { ShardedModel.count }
|
53
|
+
|
54
|
+
persisted = ShardedModel.find(document.id)
|
55
|
+
persisted.first_name.should == 'William'
|
56
|
+
persisted.last_name.should == 'Smith'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class ShardedModel
|
2
|
+
include MongoMapper::Document
|
3
|
+
|
4
|
+
key :first_name, String
|
5
|
+
key :last_name, String
|
6
|
+
shard_key :first_name
|
7
|
+
end
|
8
|
+
|
9
|
+
if ENV.fetch("ENABLE_SHARDING", "0") == "1"
|
10
|
+
client = MongoMapper.connection
|
11
|
+
database = MongoMapper.database
|
12
|
+
|
13
|
+
# https://www.mongodb.com/docs/manual/reference/command/enableSharding/#mongodb-dbcommand-dbcmd.enableSharding
|
14
|
+
client.use(:admin).command(enableSharding: database.name)
|
15
|
+
|
16
|
+
# https://www.mongodb.com/docs/manual/reference/command/shardCollection/#mongodb-dbcommand-dbcmd.shardCollection
|
17
|
+
# Note: this command automatically creates the index for the empty collection
|
18
|
+
client.use(:admin).command(
|
19
|
+
shardCollection: [database.name, ShardedModel.collection.name].join("."),
|
20
|
+
key: {
|
21
|
+
first_name: "hashed",
|
22
|
+
},
|
23
|
+
)
|
24
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
class FakeNilProxy < MongoMapper::Plugins::Associations::Proxy
|
4
|
-
def
|
4
|
+
def load_target; @target ||= nil end
|
5
5
|
end
|
6
6
|
|
7
7
|
class FakeBlankProxy < MongoMapper::Plugins::Associations::Proxy
|
8
|
-
def
|
8
|
+
def load_target; @target ||= '' end
|
9
9
|
end
|
10
10
|
|
11
11
|
class FakeNumberProxy < MongoMapper::Plugins::Associations::Proxy
|
12
|
-
def
|
12
|
+
def load_target; @target ||= 17 end
|
13
13
|
end
|
14
14
|
|
15
15
|
class FakeProxy < MongoMapper::Plugins::Associations::Proxy
|
16
|
-
def
|
16
|
+
def load_target; @target ||= [1, 2] end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "Proxy" do
|
@@ -32,7 +32,7 @@ describe "Proxy" do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should be able to inspect the proxy" do
|
35
|
-
@proxy.inspect.should ==
|
35
|
+
@proxy.inspect.should == "#<FakeProxy:#{@proxy.object_id} [1, 2]>"
|
36
36
|
end
|
37
37
|
|
38
38
|
context "nil?" do
|
@@ -108,4 +108,17 @@ describe "Proxy" do
|
|
108
108
|
lambda { @proxy.private_foo }.should raise_error(NoMethodError, /private method `private_foo' called/)
|
109
109
|
end
|
110
110
|
end
|
111
|
+
|
112
|
+
context "hash" do
|
113
|
+
it "should return the same value for the same proxy" do
|
114
|
+
proxy_a = FakeProxy.new(@owner, @association)
|
115
|
+
proxy_b = FakeProxy.new(@owner, @association)
|
116
|
+
|
117
|
+
proxy_a.hash.should == proxy_b.hash
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should return different values for different proxies" do
|
121
|
+
@proxy.hash.should_not == @nil_proxy.hash
|
122
|
+
end
|
123
|
+
end
|
111
124
|
end
|
data/spec/unit/document_spec.rb
CHANGED
@@ -220,10 +220,10 @@ describe "EmbeddedDocument" do
|
|
220
220
|
end
|
221
221
|
|
222
222
|
it "should be recorded" do
|
223
|
-
Grandparent.direct_descendants.should
|
224
|
-
Grandparent.descendants.to_set.should
|
223
|
+
Grandparent.direct_descendants.should contain_exactly(Parent)
|
224
|
+
Grandparent.descendants.to_set.should contain_exactly(Parent, Child, OtherChild)
|
225
225
|
|
226
|
-
Parent.descendants.should
|
226
|
+
Parent.descendants.should contain_exactly(Child, OtherChild)
|
227
227
|
end
|
228
228
|
end
|
229
229
|
end
|
@@ -192,15 +192,21 @@ describe "Support" do
|
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
|
-
context "NilClass
|
195
|
+
context "NilClass.from_mongo" do
|
196
196
|
it "should return nil" do
|
197
|
-
|
197
|
+
NilClass.from_mongo(nil).should be_nil
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context "NilClass.to_mongo" do
|
202
|
+
it "should return nil" do
|
203
|
+
NilClass.to_mongo(nil).should be_nil
|
198
204
|
end
|
199
205
|
end
|
200
206
|
|
201
207
|
context "NilClass#to_mongo" do
|
202
208
|
it "should return nil" do
|
203
|
-
nil.to_mongo
|
209
|
+
nil.to_mongo.should be_nil
|
204
210
|
end
|
205
211
|
end
|
206
212
|
|
data/spec/unit/inspect_spec.rb
CHANGED
@@ -31,7 +31,7 @@ describe "Inspect" do
|
|
31
31
|
klass.many :pets, :class => pets
|
32
32
|
|
33
33
|
doc = klass.new(:pets => [{:name => "Kitten"}])
|
34
|
-
doc.inspect.should =~ /_id:.*, pets:
|
34
|
+
doc.inspect.should =~ /_id:.*, pets: .*\[.*_id.*, name: "Kitten".*\]/
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should include embedded document" do
|
data/spec/unit/key_spec.rb
CHANGED
@@ -55,6 +55,7 @@ describe "Key" do
|
|
55
55
|
it "should work with name and options" do
|
56
56
|
key = Key.new(:foo, :required => true)
|
57
57
|
key.name.should == 'foo'
|
58
|
+
key.type.should be_nil
|
58
59
|
key.options[:required].should be_truthy
|
59
60
|
end
|
60
61
|
|
@@ -111,7 +112,12 @@ describe "Key" do
|
|
111
112
|
subject { @key }
|
112
113
|
|
113
114
|
it "should cast each element correctly" do
|
114
|
-
ids = [
|
115
|
+
ids = [
|
116
|
+
BSON::ObjectId.new,
|
117
|
+
BSON::ObjectId.new,
|
118
|
+
BSON::ObjectId.new.to_s,
|
119
|
+
BSON::ObjectId.new.to_s
|
120
|
+
]
|
115
121
|
subject.set(ids).should == ids.map { |id| ObjectId.to_mongo(id) }
|
116
122
|
end
|
117
123
|
end
|
@@ -71,7 +71,7 @@ describe "MongoMapper" do
|
|
71
71
|
'development' => {'hosts' => ['127.0.0.1:27017'], 'database' => 'test', 'read' => 'primary'}
|
72
72
|
}
|
73
73
|
logger = double('logger')
|
74
|
-
Mongo::Client.should_receive(:new).with(['127.0.0.1:27017'], :logger => logger, :read => :primary, :database => 'test')
|
74
|
+
Mongo::Client.should_receive(:new).with(['127.0.0.1:27017'], { :logger => logger, :read => :primary, :database => 'test' })
|
75
75
|
MongoMapper.connect('development', :logger => logger)
|
76
76
|
end
|
77
77
|
|
@@ -80,7 +80,7 @@ describe "MongoMapper" do
|
|
80
80
|
'development' => {'hosts' => ['192.168.1.1:2222'], 'database' => 'test', 'safe' => true}
|
81
81
|
}
|
82
82
|
logger = double('logger')
|
83
|
-
Mongo::Client.should_receive(:new).with(['192.168.1.1:2222'], :logger => logger, :safe => true, :database => 'test')
|
83
|
+
Mongo::Client.should_receive(:new).with(['192.168.1.1:2222'], { :logger => logger, :safe => true, :database => 'test' })
|
84
84
|
MongoMapper.connect('development', :logger => logger)
|
85
85
|
end
|
86
86
|
|
@@ -89,7 +89,7 @@ describe "MongoMapper" do
|
|
89
89
|
'development' => {'uri' => 'mongodb://127.0.0.1:27017/test', 'options'=> {:foo => 1}}
|
90
90
|
}
|
91
91
|
logger = double('logger')
|
92
|
-
Mongo::Client.should_receive(:new).with('mongodb://127.0.0.1:27017/test', :logger => logger, :foo => 1)
|
92
|
+
Mongo::Client.should_receive(:new).with('mongodb://127.0.0.1:27017/test', { :logger => logger, :foo => 1 })
|
93
93
|
MongoMapper.connect('development', :logger => logger)
|
94
94
|
end
|
95
95
|
|
@@ -97,7 +97,7 @@ describe "MongoMapper" do
|
|
97
97
|
MongoMapper.config = {
|
98
98
|
'development' => {'hosts' => ['127.0.0.1:27017'], 'database' => 'test', 'user' => 'john', 'password' => 'secret'}
|
99
99
|
}
|
100
|
-
Mongo::Client.should_receive(:new).with(['127.0.0.1:27017'], :database => 'test', :user => 'john', :password => 'secret')
|
100
|
+
Mongo::Client.should_receive(:new).with(['127.0.0.1:27017'], { :database => 'test', :user => 'john', :password => 'secret' })
|
101
101
|
MongoMapper.connect('development')
|
102
102
|
end
|
103
103
|
|
@@ -129,9 +129,14 @@ describe "MongoMapper" do
|
|
129
129
|
it "should work as shortcut for setting config, environment and options" do
|
130
130
|
config, logger = double('config'), double('logger')
|
131
131
|
MongoMapper.should_receive(:config=).with(config)
|
132
|
-
MongoMapper.should_receive(:connect).with('development', :logger => logger)
|
132
|
+
MongoMapper.should_receive(:connect).with('development', { :logger => logger })
|
133
133
|
MongoMapper.should_receive(:handle_passenger_forking).once
|
134
134
|
MongoMapper.setup(config, 'development', :logger => logger)
|
135
135
|
end
|
136
|
+
|
137
|
+
it "should use the right reconnect method" do
|
138
|
+
Mongo::Client.instance_methods.should_not include(:connect) # v1
|
139
|
+
Mongo::Client.instance_methods.should include(:reconnect) # v1
|
140
|
+
end
|
136
141
|
end
|
137
142
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-06-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mongo
|
@@ -82,6 +82,20 @@ dependencies:
|
|
82
82
|
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '1.0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rexml
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
85
99
|
description: MongoMapper is a Object-Document Mapper for Ruby and Rails
|
86
100
|
email:
|
87
101
|
- nunemaker@gmail.com
|
@@ -137,24 +151,24 @@ files:
|
|
137
151
|
- lib/mongo_mapper/plugins/associations.rb
|
138
152
|
- lib/mongo_mapper/plugins/associations/base.rb
|
139
153
|
- lib/mongo_mapper/plugins/associations/belongs_to_association.rb
|
140
|
-
- lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb
|
141
|
-
- lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb
|
142
|
-
- lib/mongo_mapper/plugins/associations/collection.rb
|
143
|
-
- lib/mongo_mapper/plugins/associations/embedded_collection.rb
|
144
|
-
- lib/mongo_mapper/plugins/associations/in_array_proxy.rb
|
145
|
-
- lib/mongo_mapper/plugins/associations/in_foreign_array_proxy.rb
|
146
154
|
- lib/mongo_mapper/plugins/associations/many_association.rb
|
147
|
-
- lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb
|
148
|
-
- lib/mongo_mapper/plugins/associations/many_documents_proxy.rb
|
149
|
-
- lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb
|
150
|
-
- lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb
|
151
|
-
- lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb
|
152
|
-
- lib/mongo_mapper/plugins/associations/one_as_proxy.rb
|
153
155
|
- lib/mongo_mapper/plugins/associations/one_association.rb
|
154
|
-
- lib/mongo_mapper/plugins/associations/
|
155
|
-
- lib/mongo_mapper/plugins/associations/
|
156
|
-
- lib/mongo_mapper/plugins/associations/
|
157
|
-
- lib/mongo_mapper/plugins/associations/proxy.rb
|
156
|
+
- lib/mongo_mapper/plugins/associations/proxy/belongs_to_polymorphic_proxy.rb
|
157
|
+
- lib/mongo_mapper/plugins/associations/proxy/belongs_to_proxy.rb
|
158
|
+
- lib/mongo_mapper/plugins/associations/proxy/collection.rb
|
159
|
+
- lib/mongo_mapper/plugins/associations/proxy/embedded_collection.rb
|
160
|
+
- lib/mongo_mapper/plugins/associations/proxy/in_array_proxy.rb
|
161
|
+
- lib/mongo_mapper/plugins/associations/proxy/in_foreign_array_proxy.rb
|
162
|
+
- lib/mongo_mapper/plugins/associations/proxy/many_documents_as_proxy.rb
|
163
|
+
- lib/mongo_mapper/plugins/associations/proxy/many_documents_proxy.rb
|
164
|
+
- lib/mongo_mapper/plugins/associations/proxy/many_embedded_polymorphic_proxy.rb
|
165
|
+
- lib/mongo_mapper/plugins/associations/proxy/many_embedded_proxy.rb
|
166
|
+
- lib/mongo_mapper/plugins/associations/proxy/many_polymorphic_proxy.rb
|
167
|
+
- lib/mongo_mapper/plugins/associations/proxy/one_as_proxy.rb
|
168
|
+
- lib/mongo_mapper/plugins/associations/proxy/one_embedded_polymorphic_proxy.rb
|
169
|
+
- lib/mongo_mapper/plugins/associations/proxy/one_embedded_proxy.rb
|
170
|
+
- lib/mongo_mapper/plugins/associations/proxy/one_proxy.rb
|
171
|
+
- lib/mongo_mapper/plugins/associations/proxy/proxy.rb
|
158
172
|
- lib/mongo_mapper/plugins/associations/single_association.rb
|
159
173
|
- lib/mongo_mapper/plugins/caching.rb
|
160
174
|
- lib/mongo_mapper/plugins/callbacks.rb
|
@@ -188,6 +202,7 @@ files:
|
|
188
202
|
- lib/mongo_mapper/plugins/sci.rb
|
189
203
|
- lib/mongo_mapper/plugins/scopes.rb
|
190
204
|
- lib/mongo_mapper/plugins/serialization.rb
|
205
|
+
- lib/mongo_mapper/plugins/shardable.rb
|
191
206
|
- lib/mongo_mapper/plugins/stats.rb
|
192
207
|
- lib/mongo_mapper/plugins/strong_parameters.rb
|
193
208
|
- lib/mongo_mapper/plugins/timestamps.rb
|
@@ -244,6 +259,7 @@ files:
|
|
244
259
|
- spec/functional/safe_spec.rb
|
245
260
|
- spec/functional/sci_spec.rb
|
246
261
|
- spec/functional/scopes_spec.rb
|
262
|
+
- spec/functional/shardable_spec.rb
|
247
263
|
- spec/functional/static_keys_spec.rb
|
248
264
|
- spec/functional/stats_spec.rb
|
249
265
|
- spec/functional/strong_parameters_spec.rb
|
@@ -255,6 +271,7 @@ files:
|
|
255
271
|
- spec/spec_helper.rb
|
256
272
|
- spec/support/matchers.rb
|
257
273
|
- spec/support/models.rb
|
274
|
+
- spec/support/sharded_model.rb
|
258
275
|
- spec/unit/associations/base_spec.rb
|
259
276
|
- spec/unit/associations/belongs_to_association_spec.rb
|
260
277
|
- spec/unit/associations/many_association_spec.rb
|
@@ -304,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
321
|
- !ruby/object:Gem::Version
|
305
322
|
version: '0'
|
306
323
|
requirements: []
|
307
|
-
rubygems_version: 3.
|
324
|
+
rubygems_version: 3.3.7
|
308
325
|
signing_key:
|
309
326
|
specification_version: 4
|
310
327
|
summary: A Ruby Object Mapper for Mongo
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module MongoMapper
|
3
|
-
module Plugins
|
4
|
-
module Associations
|
5
|
-
class Collection < Proxy
|
6
|
-
def to_ary
|
7
|
-
load_target
|
8
|
-
if target.is_a?(Array)
|
9
|
-
target.to_ary
|
10
|
-
else
|
11
|
-
Array(target)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
alias_method :to_a, :to_ary
|
16
|
-
|
17
|
-
def include?(*args)
|
18
|
-
load_target
|
19
|
-
target.include?(*args)
|
20
|
-
end
|
21
|
-
|
22
|
-
def reset
|
23
|
-
super
|
24
|
-
target = []
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|