mongo_doc 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ describe "MongoDoc::Document" do
6
6
  class FormForTest
7
7
  include MongoDoc::Document
8
8
 
9
- key :data
9
+ attr_accessor :data
10
10
  end
11
11
 
12
12
  before do
@@ -43,7 +43,7 @@ describe "MongoDoc::Document" do
43
43
  class SimpleValidationTest
44
44
  include MongoDoc::Document
45
45
 
46
- key :data
46
+ attr_accessor :data
47
47
  validates_presence_of :data
48
48
  end
49
49
 
@@ -62,13 +62,13 @@ describe "MongoDoc::Document" do
62
62
  class SaveRoot
63
63
  include MongoDoc::Document
64
64
 
65
- has_many :save_children
65
+ embed_many :save_children
66
66
  end
67
67
 
68
68
  class SaveChild
69
69
  include MongoDoc::Document
70
70
 
71
- key :data
71
+ attr_accessor :data
72
72
  end
73
73
 
74
74
  before do
@@ -200,7 +200,7 @@ describe "MongoDoc::Document" do
200
200
  class CreateTest
201
201
  include MongoDoc::Document
202
202
 
203
- key :data
203
+ attr_accessor :data
204
204
  validates_presence_of :data
205
205
  end
206
206
 
@@ -261,13 +261,13 @@ describe "MongoDoc::Document" do
261
261
  class UpdateAttributesRoot
262
262
  include MongoDoc::Document
263
263
 
264
- has_one :update_attributes_child
264
+ embed :update_attributes_child
265
265
  end
266
266
 
267
267
  class UpdateAttributesChild
268
268
  include MongoDoc::Document
269
269
 
270
- key :data
270
+ attr_accessor :data
271
271
  end
272
272
 
273
273
  let(:data) {'data'}
@@ -479,13 +479,13 @@ describe "MongoDoc::Document" do
479
479
  class BSONTest
480
480
  include MongoDoc::Document
481
481
 
482
- key :other
482
+ attr_accessor :other
483
483
  end
484
484
 
485
485
  class BSONDerived < BSONTest
486
486
  include MongoDoc::Document
487
487
 
488
- key :derived
488
+ attr_accessor :derived
489
489
  end
490
490
 
491
491
  class OtherObject
@@ -530,22 +530,22 @@ describe "MongoDoc::Document" do
530
530
  end
531
531
 
532
532
  context "associations" do
533
- context "has_one" do
534
- class TestHasOneBsonDoc
533
+ context "embed" do
534
+ class TestEmbedBsonDoc
535
535
  include MongoDoc::Document
536
536
 
537
- has_one :subdoc
537
+ embed :subdoc
538
538
  end
539
539
 
540
- class SubHasOneBsonDoc
540
+ class SubEmbedBsonDoc
541
541
  include MongoDoc::Document
542
542
 
543
- key :attr
543
+ attr_accessor :attr
544
544
  end
545
545
 
546
546
  it "#to_bson renders a bson representation of the document" do
547
- doc = TestHasOneBsonDoc.new
548
- subdoc = SubHasOneBsonDoc.new(:attr => "value")
547
+ doc = TestEmbedBsonDoc.new
548
+ subdoc = SubEmbedBsonDoc.new(:attr => "value")
549
549
  bson = doc.to_bson
550
550
  bson["subdoc"] = subdoc.to_bson
551
551
  doc.subdoc = subdoc
@@ -553,29 +553,29 @@ describe "MongoDoc::Document" do
553
553
  end
554
554
 
555
555
  it "roundtrips" do
556
- doc = TestHasOneBsonDoc.new
557
- subdoc = SubHasOneBsonDoc.new(:attr => "value")
556
+ doc = TestEmbedBsonDoc.new
557
+ subdoc = SubEmbedBsonDoc.new(:attr => "value")
558
558
  doc.subdoc = subdoc
559
559
  MongoDoc::BSON.decode(doc.to_bson).should == doc
560
560
  end
561
561
  end
562
562
 
563
- context "has_many" do
563
+ context "embed_many" do
564
564
 
565
- class SubHasManyBsonDoc
565
+ class SubEmbedManyBsonDoc
566
566
  include MongoDoc::Document
567
567
 
568
- key :attr
568
+ attr_accessor :attr
569
569
  end
570
570
 
571
- class TestHasManyBsonDoc
571
+ class TestEmbedManyBsonDoc
572
572
  include MongoDoc::Document
573
- has_many :subdoc, :class_name => 'SubHasManyBsonDoc'
573
+ embed_many :subdoc, :class_name => 'SubEmbedManyBsonDoc'
574
574
  end
575
575
 
576
576
  it "#to_bson renders a bson representation of the document" do
577
- doc = TestHasManyBsonDoc.new
578
- subdoc = SubHasManyBsonDoc.new(:attr => "value")
577
+ doc = TestEmbedManyBsonDoc.new
578
+ subdoc = SubEmbedManyBsonDoc.new(:attr => "value")
579
579
  bson = doc.to_bson
580
580
  bson["subdoc"] = [subdoc].to_bson
581
581
  doc.subdoc = subdoc
@@ -583,14 +583,14 @@ describe "MongoDoc::Document" do
583
583
  end
584
584
 
585
585
  it "roundtrips" do
586
- doc = TestHasManyBsonDoc.new
587
- subdoc = SubHasManyBsonDoc.new(:attr => "value")
586
+ doc = TestEmbedManyBsonDoc.new
587
+ subdoc = SubEmbedManyBsonDoc.new(:attr => "value")
588
588
  doc.subdoc = subdoc
589
589
  MongoDoc::BSON.decode(doc.to_bson).should == doc
590
590
  end
591
591
 
592
592
  it "roundtrips the proxy" do
593
- doc = TestHasManyBsonDoc.new(:subdoc => SubHasManyBsonDoc.new(:attr => "value"))
593
+ doc = TestEmbedManyBsonDoc.new(:subdoc => SubEmbedManyBsonDoc.new(:attr => "value"))
594
594
  MongoDoc::Associations::CollectionProxy.should === MongoDoc::BSON.decode(doc.to_bson).subdoc
595
595
  end
596
596
  end
@@ -4,19 +4,19 @@ describe "Saving embedded documents" do
4
4
  class NestedDocsRoot
5
5
  include MongoDoc::Document
6
6
 
7
- has_many :nested_children
7
+ embed_many :nested_children
8
8
  end
9
9
 
10
10
  class NestedChild
11
11
  include MongoDoc::Document
12
12
 
13
- has_one :leaf
13
+ embed :leaf
14
14
  end
15
15
 
16
16
  class LeafDoc
17
17
  include MongoDoc::Document
18
18
 
19
- key :data
19
+ attr_accessor :data
20
20
  end
21
21
 
22
22
  let(:leaf) do
@@ -42,7 +42,7 @@ describe "Saving embedded documents" do
42
42
  end
43
43
 
44
44
  context "update_attributes naive" do
45
- context "with no has_many, update_attributes" do
45
+ context "with no embed_many, update_attributes" do
46
46
  let(:root) { NestedChild.new(:leaf => leaf) }
47
47
 
48
48
  it "calls the root document's _naive_update_attributes with a full attribute path and not safe" do
@@ -56,7 +56,7 @@ describe "Saving embedded documents" do
56
56
  end
57
57
  end
58
58
 
59
- context "with has_many, update_attributes" do
59
+ context "with embed_many, update_attributes" do
60
60
  let(:root) { NestedDocsRoot.new(:nested_children => [NestedChild.new(:leaf => leaf)]) }
61
61
 
62
62
  it "calls the root document's _naive_update_attributes with a full attribute path and not safe" do
@@ -78,7 +78,7 @@ describe "Saving embedded documents" do
78
78
  leaf.stub(:_id).and_return(leaf_id)
79
79
  end
80
80
 
81
- context "with no has_many, update_attributes" do
81
+ context "with no embed_many, update_attributes" do
82
82
  let(:root) { NestedChild.new(:leaf => leaf) }
83
83
 
84
84
  it "calls the root document's _strict_update_attributes with a full attribute path and not safe" do
@@ -92,7 +92,7 @@ describe "Saving embedded documents" do
92
92
  end
93
93
  end
94
94
 
95
- context "with has_many, update_attributes" do
95
+ context "with embed_many, update_attributes" do
96
96
  let(:root) { NestedDocsRoot.new(:nested_children => [NestedChild.new(:leaf => leaf)]) }
97
97
 
98
98
  it "calls the root document's _naive_update_attributes with a full attribute path and not safe" do
data/spec/finders_spec.rb CHANGED
@@ -4,7 +4,7 @@ describe MongoDoc::Finders do
4
4
  class FindersTest
5
5
  include MongoDoc::Document
6
6
 
7
- key :data
7
+ attr_accessor :data
8
8
  end
9
9
 
10
10
  let(:criteria) { stub('criteria').as_null_object }
@@ -8,10 +8,10 @@ describe "MongoDoc::Document _id and #new_record?" do
8
8
  class Parent
9
9
  include MongoDoc::Document
10
10
 
11
- has_one :child
12
- has_many :children
11
+ embed :child
12
+ embed_many :children
13
13
 
14
- key :data
14
+ attr_accessor :data
15
15
 
16
16
  validates_presence_of :data
17
17
  end
@@ -20,7 +20,7 @@ describe "MongoDoc::Document _id and #new_record?" do
20
20
  let(:collection) { stub('collection', :save => id) }
21
21
  let(:child) { Child.new }
22
22
 
23
- context "as a has_one child" do
23
+ context "as a embed child" do
24
24
  it "when added to the parent is a new record" do
25
25
  Parent.new(:data => 'data', :child => child)
26
26
  child.should be_new_record
@@ -70,7 +70,7 @@ describe "MongoDoc::Document _id and #new_record?" do
70
70
  end
71
71
  end
72
72
 
73
- context "as a has_many child" do
73
+ context "as a embed_many child" do
74
74
  it "when added to the parent is a new record" do
75
75
  parent = Parent.new(:data => 'data')
76
76
  parent.children << child
data/spec/scope_spec.rb CHANGED
@@ -11,8 +11,8 @@ describe MongoDoc::Scope do
11
11
  class ScopeTest
12
12
  include MongoDoc::Document
13
13
 
14
- key :active
15
- key :count
14
+ attr_accessor :active
15
+ attr_accessor :count
16
16
 
17
17
  scope :active, where(:active => true)
18
18
  scope :count_lte_one, where(:count.lte => 1) do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- - 2
9
- version: 0.3.2
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Les Hill
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-11 00:00:00 -05:00
17
+ date: 2010-03-13 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -160,6 +160,7 @@ files:
160
160
  - features/support/support.rb
161
161
  - features/using_criteria.feature
162
162
  - lib/mongo_doc.rb
163
+ - lib/mongo_doc/associations.rb
163
164
  - lib/mongo_doc/associations/collection_proxy.rb
164
165
  - lib/mongo_doc/associations/document_proxy.rb
165
166
  - lib/mongo_doc/associations/hash_proxy.rb
@@ -225,6 +226,7 @@ files:
225
226
  - spec/associations/collection_proxy_spec.rb
226
227
  - spec/associations/document_proxy_spec.rb
227
228
  - spec/associations/hash_proxy_spec.rb
229
+ - spec/associations_spec.rb
228
230
  - spec/attributes_accessor_spec.rb
229
231
  - spec/attributes_spec.rb
230
232
  - spec/bson_matchers.rb
@@ -285,6 +287,7 @@ test_files:
285
287
  - spec/associations/collection_proxy_spec.rb
286
288
  - spec/associations/document_proxy_spec.rb
287
289
  - spec/associations/hash_proxy_spec.rb
290
+ - spec/associations_spec.rb
288
291
  - spec/attributes_accessor_spec.rb
289
292
  - spec/attributes_spec.rb
290
293
  - spec/bson_matchers.rb