public
Fork of sam/dm-core
Description: DataMapper - Core
Homepage: http://datamapper.org
Clone URL: git://github.com/thewordnerd/dm-core.git
moving/rewriting docs in newest yard style
Adam French (author)
Thu Jun 19 15:57:56 -0700 2008
commit  c5ecb84ee1d1422ac23da3e1e69926d8b181bdea
tree    5e918e7168d1fc9945662827a82912c09f2b6d06
parent  887befdd7c66c3bc0daed2cb44babed35b902fb9
...
113
114
115
116
 
117
118
119
...
113
114
115
 
116
117
118
119
0
@@ -113,7 +113,7 @@ begin
0
 
0
   YARD::Rake::YardocTask.new("yardoc") do |t|
0
     t.options << '--protected'
0
- t.options << '-q'
0
+ # t.options << '-q'
0
     # t.files << '...anyglobshere...'
0
   end
0
 rescue Exception
0
...
1
 
...
 
1
0
@@ -1 +1 @@
0
-See: http://wiki.datamapper.org/doku.php?id=what_needs_to_be_done
0
+See: http://github.com/sam/dm-core/wikis
...
37
38
39
 
 
40
41
42
...
44
45
46
47
48
 
 
49
50
51
 
 
 
52
53
54
...
60
61
62
63
 
 
64
65
66
67
68
69
70
71
 
 
72
73
74
 
 
75
76
77
...
160
161
162
163
164
165
 
 
 
166
167
168
169
170
171
172
173
174
 
 
 
 
 
 
 
 
 
175
176
177
...
201
202
203
204
205
 
206
207
208
209
210
211
212
213
 
214
215
216
217
 
 
 
218
219
220
...
243
244
245
246
 
247
248
249
...
251
252
253
254
 
255
256
257
...
37
38
39
40
41
42
43
44
...
46
47
48
 
 
49
50
51
 
 
52
53
54
55
56
57
...
63
64
65
 
66
67
68
69
70
71
72
73
 
 
74
75
76
 
 
77
78
79
80
81
...
164
165
166
 
 
 
167
168
169
170
 
 
 
 
 
 
 
 
171
172
173
174
175
176
177
178
179
180
181
182
...
206
207
208
 
 
209
210
211
212
 
 
 
 
 
213
214
215
216
 
217
218
219
220
221
222
...
245
246
247
 
248
249
250
251
...
253
254
255
 
256
257
258
259
0
@@ -37,6 +37,8 @@ module DataMapper
0
   module Resource
0
     @@extra_inclusions = []
0
 
0
+
0
+ ##
0
     #
0
     # Appends a module for inclusion into the model class after
0
     # DataMapper::Resource.
0
@@ -44,11 +46,12 @@ module DataMapper
0
     # This is a useful way to extend DataMapper::Resource while still retaining
0
     # a self.included method.
0
     #
0
- # @param inclusion<Module> the module that is to be appended to the module
0
- # after DataMapper::Resource
0
+ # @param [Module] inclusion the module that is to be appended to the module
0
+ # after DataMapper::Resource
0
     #
0
- # @return <TrueClass, FalseClass> whether or not the inclusions have been
0
- # successfully appended to the list
0
+ # @return [TrueClass, FalseClass] whether or not the inclusions have been
0
+ # successfully appended to the list
0
+ # @return <TrueClass, FalseClass>
0
     #-
0
     # @api public
0
     def self.append_inclusions(*inclusions)
0
@@ -60,18 +63,19 @@ module DataMapper
0
   module Model
0
     @@extra_extensions = []
0
 
0
- #
0
+ ##
0
+ #
0
     # Extends the model with this module after DataMapper::Resource has been
0
     # included.
0
     #
0
     # This is a useful way to extend DataMapper::Model while
0
     # still retaining a self.extended method.
0
     #
0
- # @param extension<Module> the module that is to be extend the model after
0
- # after DataMapper::Model
0
+ # @param [Module] extensions the module that is to be extend the model after
0
+ # after DataMapper::Model
0
     #
0
- # @return <TrueClass, FalseClass> whether or not the inclusions have been
0
- # successfully appended to the list
0
+ # @return [TrueClass, FalseClass] whether or not the inclusions have been
0
+ # successfully appended to the list
0
     #-
0
     # @api public
0
     #
0
@@ -160,18 +164,19 @@ module DataMapper
0
 
0
   ##
0
   # Setups up a connection to a data-store
0
- #
0
- # @param name<Symbol> a name for the context, defaults to :default
0
- # @param uri_or_options<Hash{Symbol => String}, Addressable::URI, String>
0
+ #
0
+ # @param Symbol name a name for the context, defaults to :default
0
+ # @param [Hash{Symbol => String}, Addressable::URI, String] uri_or_options
0
   # connection information
0
- #
0
- # @return <Repository> the resulting setup repository
0
- #
0
- # @raise <ArgumentError> "+name+ must be a Symbol, but was..." indicates that
0
- # an invalid argument was passed for name<Symbol>
0
- # @raise <ArgumentError> "+uri_or_options+ must be a Hash, URI or String, but was..."
0
- # indicates that connection information could not be gleaned from the given
0
- # uri_or_options<Hash, Addressable::URI, String>
0
+ #
0
+ # @return Repository the resulting setup repository
0
+ #
0
+ # @raise ArgumentError "+name+ must be a Symbol, but was..." indicates that
0
+ # an invalid argument was passed for name[Symbol]
0
+ # @raise [ArgumentError] "+uri_or_options+ must be a Hash, URI or String,
0
+ # but was..." indicates that connection information could not be gleaned
0
+ # from the given uri_or_options<Hash, Addressable::URI, String>
0
+ #
0
   # -
0
   # @api public
0
   def self.setup(name, uri_or_options)
0
@@ -201,20 +206,17 @@ module DataMapper
0
   end
0
 
0
   ##
0
- #
0
- # @details [Block Syntax]
0
+ # Block Syntax
0
   # Pushes the named repository onto the context-stack,
0
   # yields a new session, and pops the context-stack.
0
   #
0
- # results = DataMapper.repository(:second_database) do |current_context|
0
- # ...
0
- # end
0
- #
0
- # @details [Non-Block Syntax]
0
+ # Non-Block Syntax
0
   # Returns the current session, or if there is none,
0
   # a new Session.
0
   #
0
- # current_repository = DataMapper.repository
0
+ # @param [Symbol] args the name of a repository to act within or return, :default is default
0
+ # @yield [Proc] (optional) block to execute within the context of the named repository
0
+ # @demo spec/integration/repository_spec.rb
0
   def self.repository(*args, &block) # :yields: current_context
0
     if args.size > 1
0
       raise ArgumentError, "Can only pass in one optional argument, but passed in #{args.size} arguments", caller
0
@@ -243,7 +245,7 @@ module DataMapper
0
   ##
0
   # destructively migrates the repository upwards to match model definitions
0
   #
0
- # @param <Symbol> name repository to act on, :default is the default
0
+ # @param [Symbol] name repository to act on, :default is the default
0
   def self.migrate!(name = Repository.default_name)
0
     repository(name).migrate!
0
   end
0
@@ -251,7 +253,7 @@ module DataMapper
0
   ##
0
   # drops and recreates the repository upwards to match model definitions
0
   #
0
- # @param <Symbol> name repository to act on, :default is the default
0
+ # @param [Symbol] name repository to act on, :default is the default
0
   def self.auto_migrate!(name = Repository.default_name)
0
     repository(name).auto_migrate!
0
   end
...
26
27
28
29
 
30
31
32
...
44
45
46
47
 
48
49
50
51
52
 
53
54
 
55
56
 
57
58
59
60
 
61
62
63
 
64
65
66
...
103
104
105
106
 
107
108
109
110
111
112
113
114
 
115
116
117
 
118
119
120
...
170
171
172
173
174
175
176
177
178
...
26
27
28
 
29
30
31
32
...
44
45
46
 
47
48
49
50
51
 
52
53
 
54
55
 
56
57
58
59
 
60
61
62
 
63
64
65
66
...
103
104
105
 
106
107
108
109
110
111
112
 
 
113
114
115
 
116
117
118
119
...
169
170
171
 
 
 
 
 
172
0
@@ -26,7 +26,7 @@ module DataMapper
0
       1.0/0
0
     end
0
 
0
- #
0
+ ##
0
     # A shorthand, clear syntax for defining one-to-one, one-to-many and
0
     # many-to-many resource relationships.
0
     #
0
@@ -44,23 +44,23 @@ module DataMapper
0
     # * has n, :friendships => :friends
0
     # # identical to above example
0
     #
0
- # @param cardinality <Integer, Range, Infinity>
0
+ # @param cardinality [Integer, Range, Infinity]
0
     # cardinality that defines the association type and constraints
0
     # @param name <Symbol> the name that the association will be referenced by
0
     # @param opts <Hash> an options hash
0
     #
0
- # @option :through<Symbol> A association that this join should go through to form
0
+ # @option :through[Symbol] A association that this join should go through to form
0
     # a many-to-many association
0
- # @option :class_name<String> The name of the class to associate with, if omitted
0
+ # @option :class_name[String] The name of the class to associate with, if omitted
0
     # then the association name is assumed to match the class name
0
- # @option :remote_name<Symbol> In the case of a :through option being present, the
0
+ # @option :remote_name[Symbol] In the case of a :through option being present, the
0
     # name of the relationship on the other end of the :through-relationship
0
     # to be linked to this relationship.
0
     #
0
- # @return <DataMapper::Association::Relationship> the relationship that was
0
+ # @return [DataMapper::Association::Relationship] the relationship that was
0
     # created to reflect either a one-to-one, one-to-many or many-to-many
0
     # relationship
0
- # @raise <ArgumentError> if the cardinality was not understood. Should be a
0
+ # @raise [ArgumentError] if the cardinality was not understood. Should be a
0
     # Integer, Range or Infinity(n)
0
     #
0
     # @api public
0
@@ -103,18 +103,17 @@ module DataMapper
0
       relationship
0
     end
0
 
0
- #
0
+ ##
0
     # A shorthand, clear syntax for defining many-to-one resource relationships.
0
     #
0
     # @example [Usage]
0
     # * belongs_to :user # many_to_one, :friend
0
     # * belongs_to :friend, :class_name => 'User' # many_to_one :friends
0
     #
0
- # @param name<Symbol> The name that the association will be referenced by
0
- # @param opts<Hash> An options hash (see below)
0
+ # @param name [Symbol] The name that the association will be referenced by
0
     # @see #has
0
     #
0
- # @return <DataMapper::Association::ManyToOne> The association created
0
+ # @return [DataMapper::Association::ManyToOne] The association created
0
     # should not be accessed directly
0
     #
0
     # @api public
0
@@ -170,9 +169,4 @@ module DataMapper
0
 
0
   Model.append_extensions DataMapper::Associations
0
 
0
- # module Resource
0
- # module ClassMethods
0
- # include DataMapper::Associations
0
- # end # module ClassMethods
0
- # end # module Resource
0
 end # module DataMapper
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ module DataMapper
0
 
0
       # Setup many to many relationship between two models
0
       # -
0
- # @private
0
+ # @api private
0
       def self.setup(name, model, options = {})
0
         assert_kind_of 'name', name, Symbol
0
         assert_kind_of 'model', model, Model
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@ module DataMapper
0
 
0
       # Setup many to one relationship between two models
0
       # -
0
- # @private
0
+ # @api private
0
       def self.setup(name, model, options = {})
0
         assert_kind_of 'name', name, Symbol
0
         assert_kind_of 'model', model, Model
...
7
8
9
10
 
11
12
13
...
7
8
9
 
10
11
12
13
0
@@ -7,7 +7,7 @@ module DataMapper
0
 
0
       # Setup one to many relationship between two models
0
       # -
0
- # @private
0
+ # @api private
0
       def self.setup(name, model, options = {})
0
         assert_kind_of 'name', name, Symbol
0
         assert_kind_of 'model', model, Model
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@ module DataMapper
0
 
0
       # Setup one to one relationship between two models
0
       # -
0
- # @private
0
+ # @api private
0
       def self.setup(name, model, options = {})
0
         assert_kind_of 'name', name, Symbol
0
         assert_kind_of 'model', model, Model
...
47
48
49
50
 
51
52
53
...
58
59
60
61
 
62
63
64
...
69
70
71
72
 
73
74
75
...
47
48
49
 
50
51
52
53
...
58
59
60
 
61
62
63
64
...
69
70
71
 
72
73
74
75
0
@@ -47,7 +47,7 @@ module DataMapper
0
         Class === @child_model ? @child_model : find_const(@child_model)
0
       end
0
 
0
- # @private
0
+ # @api private
0
       def get_children(parent, options = {}, finder = :all, *args)
0
         bind_values = parent_key.get(parent)
0
         return [] if bind_values.any? { |bind_value| bind_value.nil? }
0
@@ -58,7 +58,7 @@ module DataMapper
0
         end
0
       end
0
 
0
- # @private
0
+ # @api private
0
       def get_parent(child)
0
         bind_values = child_key.get(child)
0
         return nil if bind_values.any? { |bind_value| bind_value.nil? }
0
@@ -69,7 +69,7 @@ module DataMapper
0
         end
0
       end
0
 
0
- # @private
0
+ # @api private
0
       def attach_parent(child, parent)
0
         child_key.set(child, parent && parent_key.get(parent))
0
       end
...
14
15
16
17
 
18
19
20
...
14
15
16
 
17
18
19
20
0
@@ -14,7 +14,7 @@ module DataMapper
0
         near_relationship.child_model
0
       end
0
 
0
- # @private
0
+ # @api private
0
       def get_children(parent, options = {}, finder = :all, *args)
0
         query = @query.merge(options).merge(child_key.to_query(parent_key.get(parent)))
0
 
...
2
3
4
 
 
 
 
 
 
5
6
7
8
9
10
 
 
 
 
 
 
11
12
13
...
16
17
18
 
 
 
 
 
19
20
21
...
29
30
31
 
 
 
 
 
32
33
34
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
28
29
30
31
32
33
34
35
36
37
38
...
46
47
48
49
50
51
52
53
54
55
56
0
@@ -2,12 +2,24 @@
0
 
0
 module DataMapper
0
   class AutoMigrator
0
+ ##
0
+ # Destructively automigrates the data-store to match the model
0
+ # REPEAT: THIS IS DESTRUCTIVE
0
+ #
0
+ # @param Symbol repository_name the repository to be migrated
0
+ # @calls DataMapper::Resource#auto_migrate!
0
     def self.auto_migrate(repository_name = nil)
0
       DataMapper::Resource.descendants.each do |model|
0
         model.auto_migrate!(repository_name)
0
       end
0
     end
0
 
0
+ ##
0
+ # Safely migrates the data-store to match the model
0
+ # preserving data already in the data-store
0
+ #
0
+ # @param Symbol repository_name the repository to be migrated
0
+ # @calls DataMapper::Resource#auto_upgrade!
0
     def self.auto_upgrade(repository_name = nil)
0
       DataMapper::Resource.descendants.each do |model|
0
         model.auto_upgrade!(repository_name)
0
@@ -16,6 +28,11 @@ module DataMapper
0
   end # class AutoMigrator
0
 
0
   module AutoMigrations
0
+ ##
0
+ # Destructively automigrates the data-store to match the model
0
+ # REPEAT: THIS IS DESTRUCTIVE
0
+ #
0
+ # @param Symbol repository_name the repository to be migrated
0
     def auto_migrate!(repository_name = nil)
0
       if self.superclass != Object
0
         self.superclass.auto_migrate!(repository_name)
0
@@ -29,6 +46,11 @@ module DataMapper
0
       end
0
     end
0
 
0
+ ##
0
+ # Safely migrates the data-store to match the model
0
+ # preserving data already in the data-store
0
+ #
0
+ # @param Symbol repository_name the repository to be migrated
0
     def auto_upgrade!(repository_name = nil)
0
       repository_name ||= default_repository_name
0
       repository(repository_name) do |r|
...
4
5
6
 
 
 
 
7
8
9
10
 
 
 
 
 
 
11
12
13
14
 
 
 
 
 
 
 
 
 
 
15
16
17
18
19
20
 
 
 
 
 
 
 
 
21
22
23
...
42
43
44
 
 
 
 
 
 
 
 
 
 
 
45
46
47
48
 
 
 
 
 
 
 
 
 
49
 
50
51
52
53
54
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
57
58
...
72
73
74
 
 
 
 
 
 
 
 
 
 
75
76
77
...
84
85
86
 
 
 
 
 
 
 
 
 
87
88
89
90
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
93
94
...
108
109
110
 
 
 
 
 
 
 
111
112
113
114
 
 
115
116
117
118
119
120
 
 
121
122
123
124
125
126
 
 
 
127
128
129
...
163
164
165
 
 
 
 
 
166
167
168
...
171
172
173
174
 
 
 
 
 
 
 
 
 
 
175
 
176
177
178
...
199
200
201
202
 
 
 
 
 
 
 
 
 
 
203
 
204
205
206
...
223
224
225
 
 
 
 
226
227
228
229
 
 
 
230
231
232
...
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
...
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
 
238
239
240
241
242
243
...
277
278
279
280
281
282
283
284
285
286
287
...
290
291
292
 
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
...
328
329
330
 
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
...
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
0
@@ -4,20 +4,48 @@ module DataMapper
0
 
0
     attr_reader :query
0
 
0
+ ##
0
+ # @return [Repository] the repository the collection is
0
+ # associated with
0
+ # @api public
0
     def repository
0
       query.repository
0
     end
0
 
0
+ ##
0
+ # loads the entries for the collection. Used by the
0
+ # adapters to load the instances of the declared
0
+ # model for this collection's query.
0
+ #
0
+ # @api private
0
     def load(values)
0
       add(model.load(values, query))
0
     end
0
 
0
+ ##
0
+ # reloads the entries associated with this collection
0
+ #
0
+ # @param [DataMapper::Query] query (optional) additional query
0
+ # to scope by. Use this if you want to query a collections result
0
+ # set
0
+ #
0
+ # @see DataMapper::Collection#all
0
+ #
0
+ # @api public
0
     def reload(query = {})
0
       @query = scoped_query(query)
0
       @query.update(:fields => @query.fields | @key_properties)
0
       replace(all(:reload => true))
0
     end
0
 
0
+ ##
0
+ # retrieves an entry out of the collection's entry by key
0
+ #
0
+ # @param [DataMapper::Types::*, ...] key keys which uniquely
0
+ # identify a resource in the collection
0
+ # @return [DataMapper::Resource, NilClass] the resource which
0
+ # has the supplied keys
0
+ # @api public
0
     def get(*key)
0
       if loaded?
0
         # loop over the collection to find the matching resource
0
@@ -42,17 +70,51 @@ module DataMapper
0
       end
0
     end
0
 
0
+ ##
0
+ # retrieves an entry out of the collection's entry by key,
0
+ # raising an exception if the object cannot be found
0
+ #
0
+ # @param [DataMapper::Types::*, ...] key keys which uniquely
0
+ # identify a resource in the collection
0
+ #
0
+ # @calls DataMapper::Collection#get
0
+ #
0
+ # @raise [ObjectNotFoundError] "Could not find #{model.name} with key #{key.inspect} in collection"
0
+ #
0
     def get!(*key)
0
       get(*key) || raise(ObjectNotFoundError, "Could not find #{model.name} with key #{key.inspect} in collection")
0
     end
0
 
0
+ ##
0
+ # Further refines a collection's conditions. #all provides an
0
+ # interface which simulates a database view.
0
+ #
0
+ # @param [Hash[Symbol, Object], DataMapper::Query] query parameters for
0
+ # an query within the results of the original query.
0
+ #
0
+ # @return [DataMapper::Collection] a collection whose query is the result
0
+ # of a merge
0
     def all(query = {})
0
+ # TODO: this shouldn't be a kicker if scoped_query() is called
0
       return self if query.kind_of?(Hash) ? query.empty? : query == self.query
0
       query = scoped_query(query)
0
       query.repository.read_many(query)
0
     end
0
 
0
+ ##
0
+ # Simulates Array#first by returning the first entry (when
0
+ # there are no arguments), or transforms the collection's query
0
+ # by applying :limit => n when you supply an Integer. If you
0
+ # provide a conditions hash, or a Query object, the internal
0
+ # query is scoped and a new collection is returned
0
+ #
0
+ # @param [Integer, Hash[Symbol, Object], Query] args
0
+ #
0
+ # @return [DataMapper::Resource, DataMapper::Collection] The
0
+ # first resource in the entries of this collection, or
0
+ # a new collection whose query has been merged
0
     def first(*args)
0
+ # TODO: this shouldn't be a kicker if scoped_query() is called
0
       if loaded?
0
         if args.empty?
0
           return super
0
@@ -72,6 +134,16 @@ module DataMapper
0
       end
0
     end
0
 
0
+ ##
0
+ # Simulates Array#last by returning the last entry (when
0
+ # there are no arguments), or transforming the collection's
0
+ # query by reversing the declared order, and applying
0
+ # :limit => n when you supply an Integer. If you
0
+ # supply a conditions hash, or a Query object, the
0
+ # internal query is scoped and a new collection is returned
0
+ #
0
+ # @calls Collection#first
0
+ #
0
     def last(*args)
0
       return super if loaded? && args.empty?
0
 
0
@@ -84,11 +156,40 @@ module DataMapper
0
       reversed.first(*args)
0
     end
0
 
0
+ ##
0
+ # Simulates Array#at and returns the entrie at that index.
0
+ # Also accepts negative indexes and appropriate reverses
0
+ # the order of the query
0
+ #
0
+ # @calls Collection#first
0
+ # @calls Collection#last
0
+ #
0
+ # @author adam
0
     def at(offset)
0
       return super if loaded?
0
       offset >= 0 ? first(:offset => offset) : last(:offset => offset.abs - 1)
0
     end
0
 
0
+ ##
0
+ # Simulates Array#slice and returns a new Collection
0
+ # whose query has a new offset or limit according to the
0
+ # arguments provided.
0
+ #
0
+ # If you provide a range, the min is used as the offset
0
+ # and the max minues the offset is used as the limit.
0
+ #
0
+ # @param [Integer, Array(Integer), Range] args the offset,
0
+ # offset and limit, or range indicating offsets and limits
0
+ #
0
+ # @return [DataMapper::Resource, DataMapper::Collection]
0
+ # The entry which resides at that offset and limit,
0
+ # or a new Collection object with the set limits and offset
0
+ #
0
+ # @raise [ArgumentError] "arguments may be 1 or 2 Integers,
0
+ # or 1 Range object, was: #{args.inspect}"
0
+ #
0
+ # @alias []
0
+ #
0
     def slice(*args)
0
       return at(args.first) if args.size == 1 && args.first.kind_of?(Integer)
0
 
0
@@ -108,22 +209,35 @@ module DataMapper
0
 
0
     alias [] slice
0
 
0
+ ##
0
+ #
0
+ # @return [DataMapper::Collection] a new collection whose
0
+ # query is sorted in the reverse
0
+ #
0
+ # @see Array#reverse, DataMapper#all, DataMapper::Query#reverse
0
+ #
0
     def reverse
0
       all(self.query.reverse)
0
     end
0
 
0
+ ##
0
+ # @see Array#<<
0
     def <<(resource)
0
       super
0
       relate_resource(resource)
0
       self
0
     end
0
 
0
+ ##
0
+ # @see Array#push
0
     def push(*resources)
0
       super
0
       resources.each { |resource| relate_resource(resource) }
0
       self
0
     end
0
-
0
+
0
+ ##
0
+ # @see Array#unshift
0
     def unshift(*resources)
0
       super
0
       resources.each { |resource| relate_resource(resource) }
0
@@ -163,6 +277,11 @@ module DataMapper
0
       self
0
     end
0
 
0
+ ##
0
+ # creates a new array, saves it, and << it onto the collection
0
+ #
0
+ # @param Hash[Symbol => Object] attributes attributes which
0
+ # the new resource should have.
0
     def create(attributes = {})
0
       repository.scope do
0
         resource = model.create(default_attributes.merge(attributes))
0
@@ -171,8 +290,18 @@ module DataMapper
0
       end
0
     end
0
 
0
- # TODO: delegate to Model.update
0
+ ##
0
+ # batch updates the entries belongs to this collection.
0
+ #
0
+ # @example Reached the Age of Alchohol Consumption
0
+ # Person.all(:age.gte => 21).update(:allow_beer => true)
0
+ #
0
+ # @return [TrueClass, FalseClass]
0
+ # TrueClass indicates that all entries were affected
0
+ # FalseClass indicates that some entries were affected
0
+ #
0
     def update(attributes = {},preload=false)
0
+ # TODO: delegate to Model.update
0
       return true if attributes.empty?
0
 
0
       dirty_attributes, keys_to_reload = {}, {}
0
@@ -199,8 +328,18 @@ module DataMapper
0
       return loaded? ? affected == size : affected > 0
0
     end
0
 
0
- # TODO: delegate to Model.destroy
0
+ ##
0
+ # batch destroy the entries belongs to this collection.
0
+ #
0
+ # @example The War On Terror (if only it were this easy)
0
+ # Person.all(:terrorist => true).destroy() #
0
+ #
0
+ # @return [TrueClass, FalseClass]
0
+ # TrueClass indicates that all entries were affected
0
+ # FalseClass indicates that some entries were affected
0
+ #