mongoo 0.4.8 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.8
1
+ 0.4.9
data/lib/mongoo.rb CHANGED
@@ -9,6 +9,7 @@ end
9
9
  module Mongoo
10
10
  INDEX_META = {}
11
11
  ATTRIBUTE_META = {}
12
+ EMBEDS_META = {}
12
13
 
13
14
  class << self
14
15
  attr_accessor :verbose_debug
@@ -55,7 +56,6 @@ require "mongoo/modifiers"
55
56
  require "mongoo/core"
56
57
  require "mongoo/base"
57
58
  require "mongoo/embedded/base"
58
- require "mongoo/embedded/array_proxy"
59
59
  require "mongoo/embedded/hash_proxy"
60
60
  require "mongoo/mongohash"
61
61
  require "mongoo/identity_map"
data/lib/mongoo/base.rb CHANGED
@@ -9,17 +9,5 @@ module Mongoo
9
9
 
10
10
  define_model_callbacks :insert, :update, :remove
11
11
 
12
- def embedded_array_proxy(attrib, klass)
13
- Mongoo::Embedded::ArrayProxy.new(self, attrib, klass)
14
- end
15
-
16
- def embedded_hash_proxy(attrib, klass)
17
- Mongoo::Embedded::HashProxy.new(self, attrib, klass)
18
- end
19
-
20
- def embedded_doc(attrib, klass)
21
- klass.new(self, attrib)
22
- end
23
-
24
12
  end
25
13
  end
data/lib/mongoo/core.rb CHANGED
@@ -5,6 +5,96 @@ module Mongoo
5
5
  include ActiveModel::Validations
6
6
  extend ActiveModel::Naming
7
7
 
8
+ def self.embeds_meta
9
+ Mongoo::EMBEDS_META[self.to_s] ||= {}
10
+ end
11
+
12
+ def self.embeds_many(attrib_key, opts)
13
+ raise(ArgumentError, "missing opt :as") unless opts[:as]
14
+ raise(ArgumentError, "missing opt :class") unless opts[:class]
15
+
16
+ self.embeds_meta["embeds_many"] ||= {}
17
+ self.embeds_meta["embeds_many"][attrib_key] = opts
18
+
19
+ define_embeds_many_methods
20
+ end
21
+
22
+ def self.define_embeds_many_methods
23
+ (self.embeds_meta["embeds_many"] || {}).each do |attrib_key, opts|
24
+ define_method(opts[:as]) do
25
+ if val = instance_variable_get("@#{opts[:as]}")
26
+ val
27
+ else
28
+ instance_variable_set("@#{opts[:as]}",
29
+ embedded_hash_proxy(get_or_set(attrib_key,{}), eval(opts[:class])))
30
+ end
31
+ end # define_method
32
+ unless opts[:validate] == false
33
+ define_method("validate_#{opts[:as]}") do
34
+ send(opts[:as]).each do |k,v|
35
+ unless v.valid?
36
+ v.errors.each do |field, messages|
37
+ errors.add "#{attrib_key}.#{k}.#{field}", messages
38
+ end
39
+ end
40
+ end
41
+ end # define_method
42
+ validate "validate_#{opts[:as]}"
43
+ end
44
+ end
45
+ end
46
+
47
+ def self.embeds_one(attrib_key, opts)
48
+ raise(ArgumentError, "missing opt :as") unless opts[:as]
49
+ raise(ArgumentError, "missing opt :class") unless opts[:class]
50
+
51
+ self.embeds_meta["embeds_one"] ||= {}
52
+ self.embeds_meta["embeds_one"][attrib_key] = opts
53
+
54
+ define_embeds_one_methods
55
+ end
56
+
57
+ def self.define_embeds_one_methods
58
+ (self.embeds_meta["embeds_one"] || {}).each do |attrib_key, opts|
59
+ define_method(opts[:as]) do
60
+ if val = instance_variable_get("@#{opts[:as]}")
61
+ val
62
+ else
63
+ if hash = get(attrib_key)
64
+ instance_variable_set("@#{opts[:as]}",
65
+ embedded_doc(hash, eval(opts[:class])))
66
+ end
67
+ end
68
+ end
69
+
70
+ define_method("#{opts[:as]}=") do |obj|
71
+ set(attrib_key, (obj.nil? ? nil : obj.to_hash))
72
+ send("#{opts[:as]}")
73
+ end
74
+
75
+ unless opts[:validate] == false
76
+ define_method("validate_#{opts[:as]}") do
77
+ if v = send(opts[:as])
78
+ unless v.valid?
79
+ v.errors.each do |field, messages|
80
+ errors.add "#{attrib_key}.#{field}", messages
81
+ end
82
+ end
83
+ end
84
+ end # define_method
85
+ validate "validate_#{opts[:as]}"
86
+ end
87
+ end
88
+ end
89
+
90
+ def embedded_hash_proxy(attrib, klass)
91
+ Mongoo::Embedded::HashProxy.new(self, attrib, klass)
92
+ end
93
+
94
+ def embedded_doc(attrib, klass)
95
+ klass.new(self, attrib)
96
+ end
97
+
8
98
  def self.attribute(name, opts={})
9
99
  raise ArgumentError.new("missing :type") unless opts[:type]
10
100
  self.attributes[name.to_s] = opts
@@ -20,6 +20,10 @@ module Mongoo
20
20
  build raw[k]
21
21
  end
22
22
 
23
+ def delete(k)
24
+ raw.delete(k)
25
+ end
26
+
23
27
  def []=(k,o)
24
28
  raw[k] = o.to_hash
25
29
  end
data/mongoo.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoo}
8
- s.version = "0.4.8"
8
+ s.version = "0.4.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Myles"]
@@ -32,7 +32,6 @@ Gem::Specification.new do |s|
32
32
  "lib/mongoo/changelog.rb",
33
33
  "lib/mongoo/core.rb",
34
34
  "lib/mongoo/cursor.rb",
35
- "lib/mongoo/embedded/array_proxy.rb",
36
35
  "lib/mongoo/embedded/base.rb",
37
36
  "lib/mongoo/embedded/hash_proxy.rb",
38
37
  "lib/mongoo/hash_ext.rb",
@@ -52,7 +51,7 @@ Gem::Specification.new do |s|
52
51
  s.homepage = %q{http://github.com/benmyles/mongoo}
53
52
  s.licenses = ["MIT"]
54
53
  s.require_paths = ["lib"]
55
- s.rubygems_version = %q{1.6.1}
54
+ s.rubygems_version = %q{1.6.2}
56
55
  s.summary = %q{Object mapper for MongoDB}
57
56
  s.test_files = [
58
57
  "test/helper.rb",
@@ -1,22 +1,17 @@
1
1
  require 'helper'
2
2
 
3
3
  class Book < Mongoo::Base
4
- attribute "title", :type => :string
5
- attribute "chapters", :type => :array
6
- attribute "authors", :type => :hash
7
- attribute "sample_chapter", :type => :hash
8
-
9
- def chapters
10
- @chapters ||= embedded_array_proxy(get_or_set('chapters',[]), Book::Chapter)
11
- end
4
+ attribute "title", :type => :string
12
5
 
13
- def authors
14
- @authors ||= embedded_hash_proxy(get_or_set('authors', {}), Book::Author)
15
- end
6
+ attribute "chapters", :type => :hash
7
+ attribute "authors", :type => :hash
8
+ attribute "sample_chapter", :type => :hash
9
+ attribute "purchases", :type => :hash
16
10
 
17
- def sample_chapter
18
- @sample_chapter ||= embedded_doc(get_or_set('sample_chapter', {}), Book::Chapter)
19
- end
11
+ embeds_one "sample_chapter", :as => "sample_chapter", :class => "Book::Chapter"
12
+ embeds_many "chapters", :as => "chapters", :class => 'Book::Chapter'
13
+ embeds_many "authors", :as => "authors", :class => 'Book::Author'
14
+ embeds_many "purchases", :as => "purchases", :class => 'Book::Purchase'
20
15
  end
21
16
 
22
17
  class Book::Chapter < Mongoo::Embedded::Base
@@ -28,32 +23,25 @@ class Book::Author < Mongoo::Embedded::Base
28
23
  attribute "last_name", :type => :string
29
24
  end
30
25
 
31
- class TestEmbedded < Test::Unit::TestCase
32
- def setup
33
- Book.collection.drop
34
- end
26
+ class Book::Purchase < Mongoo::Embedded::Base
27
+ attribute "payment_type", :type => :string
35
28
 
36
- should "be able to work with embedded doc arrays" do
37
- b = Book.new
38
- b.title = "Skydiving Instruction Manual"
29
+ attribute "customer", :type => :hash
30
+ embeds_one "customer", :as => "customer", :class => 'Book::Purchase::Customer'
39
31
 
40
- b.chapters.push(b.chapters.build(title: "How to Land"))
41
-
42
- b2 = Book.new(title: "Something Else")
43
- b2.chapters.push b2.chapters.build(title: "How to Transcend Fear")
44
-
45
- assert_equal [], b.chapters.raw & b2.chapters.raw
46
-
47
- b2.chapters.push b2.chapters.build({title: "How to Land"})
48
-
49
- assert_equal([{"title"=>"How to Land"}], b.chapters.raw & b2.chapters.raw)
50
-
51
- assert_equal b.chapters.range(0,0), b2.chapters.range(1,1)
52
- assert_not_equal b.chapters.range(0,0), b2.chapters.range(0,0)
32
+ validates_presence_of :payment_type
33
+ end
53
34
 
54
- assert_equal 2, b2.chapters.size
35
+ class Book::Purchase::Customer < Mongoo::Embedded::Base
36
+ attribute "name", :type => :string
37
+ attribute "phone", :type => :string
38
+ validates_presence_of :name
39
+ validates_presence_of :phone
40
+ end
55
41
 
56
- assert_equal "How to Transcend Fear", b2.chapters[0].title
42
+ class TestEmbedded < Test::Unit::TestCase
43
+ def setup
44
+ Book.collection.drop
57
45
  end
58
46
 
59
47
  should "be able to work with embedded doc hashes" do
@@ -78,6 +66,7 @@ class TestEmbedded < Test::Unit::TestCase
78
66
 
79
67
  should "be able to work with a single embedded doc" do
80
68
  b = Book.new(title: "BASE Jumping Basics")
69
+ b.sample_chapter = Book::Chapter.new(b, {})
81
70
  b.sample_chapter.title = "Understanding the Risks"
82
71
  assert_equal "Understanding the Risks", b.g('sample_chapter')['title']
83
72
  b.insert!
@@ -85,4 +74,65 @@ class TestEmbedded < Test::Unit::TestCase
85
74
  assert_equal "Understanding the Risks", b.sample_chapter.title
86
75
  assert_equal "Understanding the Risks", b.g('sample_chapter')['title']
87
76
  end
77
+
78
+ should "validate embedded docs and can have nested embeds" do
79
+ b = Book.new(title: "BASE Jumping Basics")
80
+ b.insert!
81
+
82
+ purchase_id = BSON::ObjectId.new.to_s
83
+ b.purchases[purchase_id] = b.purchases.build({})
84
+ assert !b.valid?
85
+ assert_equal({:"purchases.#{purchase_id}.payment_type"=>["can't be blank"]}, b.errors)
86
+ b.purchases[purchase_id].payment_type = "Cash"
87
+ assert b.valid?
88
+ b.update!
89
+
90
+ b = Book.find_one(b.id)
91
+ assert_equal "Cash", b.purchases[purchase_id].payment_type
92
+ assert_nil b.purchases[purchase_id].customer
93
+ b.purchases[purchase_id].customer = Book::Purchase::Customer.new(b.purchases[purchase_id], name: "Jiminy")
94
+ assert_equal "Jiminy", b.purchases[purchase_id].customer.name
95
+ assert !b.valid?
96
+ assert_equal({:"purchases.#{purchase_id}.customer.phone"=>["can't be blank"]}, b.errors)
97
+ b.purchases[purchase_id].customer.phone = "123"
98
+ assert b.valid?
99
+ b.update!
100
+ b = Book.find_one(b.id)
101
+ assert_equal "Jiminy", b.purchases[purchase_id].customer.name
102
+ b.purchases[purchase_id].customer = nil
103
+ assert_equal [[:unset, "purchases.#{purchase_id}.customer", 1]], b.changelog
104
+ b.update!
105
+ b = Book.find_one(b.id)
106
+ assert_nil b.purchases[purchase_id].customer
107
+ assert_equal [], b.changelog
108
+ end
109
+
110
+ should "be able to delete a doc in an embeds_many" do
111
+ b = Book.new(title: "BASE Jumping Basics")
112
+
113
+ purchase_id = BSON::ObjectId.new.to_s
114
+ b.purchases[purchase_id] = b.purchases.build({payment_type: "Cash"})
115
+
116
+ purchase_id2 = BSON::ObjectId.new.to_s
117
+ b.purchases[purchase_id2] = b.purchases.build({payment_type: "Card"})
118
+
119
+ assert_equal 3, b.changelog.size
120
+ b.purchases.delete(purchase_id2)
121
+ assert_equal 2, b.changelog.size
122
+ b.purchases[purchase_id2] = b.purchases.build({payment_type: "Card"})
123
+ assert_equal 3, b.changelog.size
124
+
125
+ b.insert!
126
+
127
+ assert_equal 2, b.purchases.size
128
+
129
+ b.purchases.delete(purchase_id2)
130
+ assert_equal 1, b.purchases.size
131
+ assert_equal 1, b.changelog.size
132
+ b.update!
133
+ assert_equal 1, b.purchases.size
134
+
135
+ b = Book.find_one(b.id)
136
+ assert_equal 1, b.purchases.size
137
+ end
88
138
  end
metadata CHANGED
@@ -1,149 +1,146 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mongoo
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.9
4
5
  prerelease:
5
- version: 0.4.8
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Ben Myles
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-06-07 00:00:00 -07:00
12
+ date: 2011-06-07 00:00:00.000000000 -07:00
14
13
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: i18n
18
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2157581440 !ruby/object:Gem::Requirement
19
18
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
23
22
  version: 0.4.1
24
23
  type: :runtime
25
24
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *2157581440
26
+ - !ruby/object:Gem::Dependency
28
27
  name: activesupport
29
- requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirement: &2157579300 !ruby/object:Gem::Requirement
30
29
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
34
33
  version: 3.0.3
35
34
  type: :runtime
36
35
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *2157579300
37
+ - !ruby/object:Gem::Dependency
39
38
  name: activemodel
40
- requirement: &id003 !ruby/object:Gem::Requirement
39
+ requirement: &2157573100 !ruby/object:Gem::Requirement
41
40
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
45
44
  version: 3.0.3
46
45
  type: :runtime
47
46
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
47
+ version_requirements: *2157573100
48
+ - !ruby/object:Gem::Dependency
50
49
  name: mongo
51
- requirement: &id004 !ruby/object:Gem::Requirement
50
+ requirement: &2157571300 !ruby/object:Gem::Requirement
52
51
  none: false
53
- requirements:
52
+ requirements:
54
53
  - - ~>
55
- - !ruby/object:Gem::Version
54
+ - !ruby/object:Gem::Version
56
55
  version: 1.3.1
57
56
  type: :runtime
58
57
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
58
+ version_requirements: *2157571300
59
+ - !ruby/object:Gem::Dependency
61
60
  name: ruby-debug19
62
- requirement: &id005 !ruby/object:Gem::Requirement
61
+ requirement: &2157569760 !ruby/object:Gem::Requirement
63
62
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
68
67
  type: :development
69
68
  prerelease: false
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
69
+ version_requirements: *2157569760
70
+ - !ruby/object:Gem::Dependency
72
71
  name: shoulda
73
- requirement: &id006 !ruby/object:Gem::Requirement
72
+ requirement: &2157568060 !ruby/object:Gem::Requirement
74
73
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
79
78
  type: :development
80
79
  prerelease: false
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
80
+ version_requirements: *2157568060
81
+ - !ruby/object:Gem::Dependency
83
82
  name: bundler
84
- requirement: &id007 !ruby/object:Gem::Requirement
83
+ requirement: &2157566000 !ruby/object:Gem::Requirement
85
84
  none: false
86
- requirements:
85
+ requirements:
87
86
  - - ~>
88
- - !ruby/object:Gem::Version
87
+ - !ruby/object:Gem::Version
89
88
  version: 1.0.0
90
89
  type: :development
91
90
  prerelease: false
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
91
+ version_requirements: *2157566000
92
+ - !ruby/object:Gem::Dependency
94
93
  name: jeweler
95
- requirement: &id008 !ruby/object:Gem::Requirement
94
+ requirement: &2157554600 !ruby/object:Gem::Requirement
96
95
  none: false
97
- requirements:
96
+ requirements:
98
97
  - - ~>
99
- - !ruby/object:Gem::Version
98
+ - !ruby/object:Gem::Version
100
99
  version: 1.5.1
101
100
  type: :development
102
101
  prerelease: false
103
- version_requirements: *id008
104
- - !ruby/object:Gem::Dependency
102
+ version_requirements: *2157554600
103
+ - !ruby/object:Gem::Dependency
105
104
  name: rcov
106
- requirement: &id009 !ruby/object:Gem::Requirement
105
+ requirement: &2157550280 !ruby/object:Gem::Requirement
107
106
  none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: "0"
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
112
111
  type: :development
113
112
  prerelease: false
114
- version_requirements: *id009
115
- - !ruby/object:Gem::Dependency
113
+ version_requirements: *2157550280
114
+ - !ruby/object:Gem::Dependency
116
115
  name: perftools.rb
117
- requirement: &id010 !ruby/object:Gem::Requirement
116
+ requirement: &2157548520 !ruby/object:Gem::Requirement
118
117
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- version: "0"
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
123
122
  type: :development
124
123
  prerelease: false
125
- version_requirements: *id010
126
- - !ruby/object:Gem::Dependency
124
+ version_requirements: *2157548520
125
+ - !ruby/object:Gem::Dependency
127
126
  name: bson_ext
128
- requirement: &id011 !ruby/object:Gem::Requirement
127
+ requirement: &2157541520 !ruby/object:Gem::Requirement
129
128
  none: false
130
- requirements:
129
+ requirements:
131
130
  - - ~>
132
- - !ruby/object:Gem::Version
131
+ - !ruby/object:Gem::Version
133
132
  version: 1.3.1
134
133
  type: :development
135
134
  prerelease: false
136
- version_requirements: *id011
135
+ version_requirements: *2157541520
137
136
  description: Simple object mapper for MongoDB
138
137
  email: ben.myles@gmail.com
139
138
  executables: []
140
-
141
139
  extensions: []
142
-
143
- extra_rdoc_files:
140
+ extra_rdoc_files:
144
141
  - LICENSE.txt
145
142
  - README.rdoc
146
- files:
143
+ files:
147
144
  - .document
148
145
  - .rvmrc
149
146
  - CHANGELOG
@@ -159,7 +156,6 @@ files:
159
156
  - lib/mongoo/changelog.rb
160
157
  - lib/mongoo/core.rb
161
158
  - lib/mongoo/cursor.rb
162
- - lib/mongoo/embedded/array_proxy.rb
163
159
  - lib/mongoo/embedded/base.rb
164
160
  - lib/mongoo/embedded/hash_proxy.rb
165
161
  - lib/mongoo/hash_ext.rb
@@ -177,36 +173,34 @@ files:
177
173
  - test/test_performance.rb
178
174
  has_rdoc: true
179
175
  homepage: http://github.com/benmyles/mongoo
180
- licenses:
176
+ licenses:
181
177
  - MIT
182
178
  post_install_message:
183
179
  rdoc_options: []
184
-
185
- require_paths:
180
+ require_paths:
186
181
  - lib
187
- required_ruby_version: !ruby/object:Gem::Requirement
182
+ required_ruby_version: !ruby/object:Gem::Requirement
188
183
  none: false
189
- requirements:
190
- - - ">="
191
- - !ruby/object:Gem::Version
192
- hash: 3583778272833589372
193
- segments:
184
+ requirements:
185
+ - - ! '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ segments:
194
189
  - 0
195
- version: "0"
196
- required_rubygems_version: !ruby/object:Gem::Requirement
190
+ hash: 2847002487203023580
191
+ required_rubygems_version: !ruby/object:Gem::Requirement
197
192
  none: false
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: "0"
193
+ requirements:
194
+ - - ! '>='
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
202
197
  requirements: []
203
-
204
198
  rubyforge_project:
205
- rubygems_version: 1.6.1
199
+ rubygems_version: 1.6.2
206
200
  signing_key:
207
201
  specification_version: 3
208
202
  summary: Object mapper for MongoDB
209
- test_files:
203
+ test_files:
210
204
  - test/helper.rb
211
205
  - test/test_activemodel.rb
212
206
  - test/test_embedded.rb
@@ -1,53 +0,0 @@
1
- module Mongoo
2
- module Embedded
3
- class ArrayProxy
4
-
5
- def initialize(doc, array, klass)
6
- @doc = doc
7
- @array = array
8
- @klass = klass
9
- end
10
-
11
- def build(hash)
12
- @klass.new(@doc,hash)
13
- end
14
-
15
- def raw
16
- @array
17
- end
18
-
19
- def [](index)
20
- if res = raw[index]
21
- build(res)
22
- end
23
- end
24
-
25
- def range(min=0, max=-1)
26
- if res = raw[min..max]
27
- res.collect { |h| build(h) }
28
- end
29
- end
30
-
31
- def all
32
- range
33
- end
34
-
35
- def each
36
- raw.each { |h| yield(build(h)) }
37
- end
38
-
39
- def push(o)
40
- raw << o.to_hash
41
- end
42
-
43
- def pop(o)
44
- raw.pop o.to_hash
45
- end
46
-
47
- def size
48
- raw.size
49
- end
50
-
51
- end # ArrayProxy
52
- end # Embedded
53
- end # Mongoo