Skip to content

Commit 94fdc7d

Browse files
MONGOID-5415: Add splats to code docs (#5400)
* Correct splats in docs. * Requested fixes * Line wrap Co-authored-by: shields <[email protected]>
1 parent 68d200d commit 94fdc7d

File tree

28 files changed

+81
-76
lines changed

28 files changed

+81
-76
lines changed

lib/mongoid/association/accessors.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def without_autobuild
251251
# @example Parse the args.
252252
# doc.parse_args(:name => "Joe")
253253
#
254-
# @param [ Array ] args The arguments.
254+
# @param [ Hash... ] *args The arguments.
255255
#
256256
# @return [ Array<Hash> ] The attributes and options.
257257
def parse_args(*args)

lib/mongoid/association/builders.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module Builders
2727
# @example Parse the args.
2828
# doc.parse_args(:name => "Joe")
2929
#
30-
# @param [ Array ] args The arguments.
30+
# @param [ Hash... ] *args The arguments.
3131
#
3232
# @return [ Array<Hash> ] The attributes and options.
3333
def parse_args(*args)

lib/mongoid/association/embedded/embeds_many/proxy.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Proxy < Association::Many
1919
# @example Push a document.
2020
# person.addresses.push(address)
2121
#
22-
# @param [ Document | Array<Document> ] args Any number of documents.
22+
# @param [ Document... ] *args Any number of documents.
2323
def <<(*args)
2424
docs = args.flatten
2525
return concat(docs) if docs.size > 1
@@ -117,7 +117,7 @@ def clear
117117
# @example Use #persisted? inside block to count persisted documents.
118118
# person.addresses.count { |a| a.persisted? && a.country == "FR" }
119119
#
120-
# @param [ Object | Array<Object> ] args Args to delegate to the target.
120+
# @param [ Object... ] *args Args to delegate to the target.
121121
#
122122
# @return [ Integer ] The total number of persisted embedded docs, as
123123
# flagged by the #persisted? method.
@@ -235,7 +235,7 @@ def exists?
235235
# @example Finds the first matching document using a block.
236236
# person.addresses.find { |addr| addr.state == 'CA' }
237237
#
238-
# @param [ Array<Object> ] args Various arguments.
238+
# @param [ Object... ] *args Various arguments.
239239
# @param [ Proc ] block Optional block to pass.
240240
#
241241
# @return [ Document | Array<Document> | nil ] A document or matching documents.
@@ -430,10 +430,10 @@ def integrate(document)
430430
# If the method exists on the array, use the default proxy behavior.
431431
#
432432
# @param [ Symbol | String ] name The name of the method.
433-
# @param [ Array ] args The method args
433+
# @param [ Object... ] *args The method args.
434434
# @param [ Proc ] block Optional block to pass.
435435
#
436-
# @return [ Criteria, Object ] A Criteria or return value from the target.
436+
# @return [ Criteria | Object ] A Criteria or return value from the target.
437437
ruby2_keywords def method_missing(name, *args, &block)
438438
return super if _target.respond_to?(name)
439439
klass.send(:with_scope, criteria) do

lib/mongoid/association/proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def characterize_one(document)
118118
# to the target of the proxy. This can be overridden in special cases.
119119
#
120120
# @param [ String | Symbol ] name The name of the method.
121-
# @param [ Array ] args The arguments passed to the method.
121+
# @param [ Object... ] *args The arguments passed to the method.
122122
ruby2_keywords def method_missing(name, *args, &block)
123123
_target.send(name, *args, &block)
124124
end

lib/mongoid/association/referenced/counter_cache.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module CounterCache
1313
# @example Reset the given counter cache
1414
# post.reset_counters(:comments)
1515
#
16-
# @param [ Symbol | Array ] counters One or more counter caches to reset
16+
# @param [ Symbol... ] *counters One or more counter caches to reset.
1717
def reset_counters(*counters)
1818
self.class.with(persistence_context) do |_class|
1919
_class.reset_counters(self, *counters)
@@ -30,7 +30,7 @@ module ClassMethods
3030
# Post.reset_counters('50e0edd97c71c17ea9000001', :comments)
3131
#
3232
# @param [ String ] id The id of the object that will be reset.
33-
# @param [ Symbol | Array ] counters One or more counter caches to reset
33+
# @param [ Symbol... ] *counters One or more counter caches to reset.
3434
def reset_counters(id, *counters)
3535
document = id.is_a?(Document) ? id : find(id)
3636
counters.each do |name|

lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Proxy < Referenced::HasMany::Proxy
2121
# @example Concat with other documents.
2222
# person.posts.concat([ post_one, post_two ])
2323
#
24-
# @param [ Document | Array<Document> ] args Any number of documents.
24+
# @param [ Document... ] *args Any number of documents.
2525
#
2626
# @return [ Array<Document> ] The loaded docs.
2727
def <<(*args)

lib/mongoid/association/referenced/has_many/enumerable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ def empty?
215215
# completely depending on whether it is iterated to completion.
216216
#
217217
# This method can take a parameter and a block. The behavior with
218-
# either the paramater or the block is delegated to the standard
218+
# either the parameter or the block is delegated to the standard
219219
# library Enumerable module.
220220
#
221221
# Note that when Enumerable's any? method is invoked with both
222222
# a block and a pattern, it only uses the pattern.
223223
#
224-
# @param [ Object ] condition The condition that documents
224+
# @param [ Object... ] *args The condition that documents
225225
# must satisfy. See Enumerable documentation for details.
226226
#
227227
# @return [ true | false ] If the association has any documents.

lib/mongoid/association/referenced/has_many/proxy.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Proxy < Association::Many
2525
# @example Concat with other documents.
2626
# person.posts.concat([ post_one, post_two ])
2727
#
28-
# @param [ Document | Array<Document> ] args Any number of documents.
28+
# @param [ Document... ] *args Any number of documents.
2929
#
3030
# @return [ Array<Document> ] The loaded docs.
3131
def <<(*args)
@@ -199,7 +199,7 @@ def exists?
199199
# @note This will keep matching documents in memory for iteration
200200
# later.
201201
#
202-
# @param [ Object | Array<Object> ] *args The ids.
202+
# @param [ [ Object | Array<Object> ]... ] *args The ids.
203203
# @param [ Proc ] block Optional block to pass.
204204
#
205205
# @return [ Document | Array<Document> | nil ] A document or matching documents.
@@ -414,7 +414,7 @@ def cascade!(document)
414414
# If the method exists on the array, use the default proxy behavior.
415415
#
416416
# @param [ Symbol | String ] name The name of the method.
417-
# @param [ Array ] args The method args
417+
# @param [ Object... ] *args The method args
418418
# @param [ Proc ] block Optional block to pass.
419419
#
420420
# @return [ Criteria | Object ] A Criteria or return value from the target.

lib/mongoid/association/reflections.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def reflect_on_association(name)
2525
# @example Find multiple association metadata by macro.
2626
# person.reflect_on_all_associations(:embeds_many)
2727
#
28-
# @param [ Array<Symbol> ] macros The association macros.
28+
# @param [ Symbol... ] *macros The association macros.
2929
#
3030
# @return [ Array<Association> ] The matching association metadata.
3131
def reflect_on_all_association(*macros)
@@ -51,7 +51,7 @@ def reflect_on_association(name)
5151
# @example Find multiple association metadata by macro.
5252
# Person.reflect_on_all_associations(:embeds_many)
5353
#
54-
# @param [ Array<Symbol> ] macros The association macros.
54+
# @param [ Symbol... ] *macros The association macros.
5555
#
5656
# @return [ Array<Association> ] The matching association metadata.
5757
def reflect_on_all_associations(*macros)

lib/mongoid/attributes/dynamic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def inspect_dynamic_fields
115115
# document.method_missing(:test)
116116
#
117117
# @param [ String | Symbol ] name The name of the method.
118-
# @param [ Array ] args The arguments to the method.
118+
# @param [ Object... ] *args The arguments to the method.
119119
#
120120
# @return [ Object ] The result of the method call.
121121
def method_missing(name, *args)

lib/mongoid/attributes/nested.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ module ClassMethods
3333
# accepts_nested_attributes_for :addresses, :game, :posts
3434
# end
3535
#
36-
# @param [ Array<Symbol> | Hash ] args A list of association names, followed
37-
# by a hash of options.
36+
# @param [ Symbol..., Hash ] *args A list of association names, followed
37+
# by an optional hash of options.
3838
#
3939
# @option *args [ true | false ] :allow_destroy Can deletion occur?
4040
# @option *args [ Proc | Symbol ] :reject_if Block or symbol pointing

lib/mongoid/attributes/readonly.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module ClassMethods
6161
# attr_readonly :name, :genre
6262
# end
6363
#
64-
# @param [ Array<Symbol> ] names The names of the fields.
64+
# @param [ Symbol... ] *names The names of the fields.
6565
def attr_readonly(*names)
6666
names.each do |name|
6767
readonly_attributes << database_field_name(name)

lib/mongoid/contextual/atomic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def set(sets)
150150
# @example Unset the field on the matches.
151151
# context.unset(:name)
152152
#
153-
# @param [ String | Symbol | Array<String | Symbol> | Hash ] args
153+
# @param [ [ String | Symbol | Array<String | Symbol> | Hash ]... ] *args
154154
# The name(s) of the field(s) to unset.
155155
# If a Hash is specified, its keys will be used irrespective of what
156156
# each key's value is, even if the value is nil or false.

lib/mongoid/contextual/memory.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def limit(value)
237237
# @example Get the values in memory.
238238
# context.pluck(:name)
239239
#
240-
# @param [ String | Symbol ] *fields Field(s) to pluck.
240+
# @param [ [ String | Symbol ]... ] *fields Field(s) to pluck.
241241
#
242242
# @return [ Array<Object> | Array<Array<Object>> ] The plucked values.
243243
def pluck(*fields)
@@ -255,9 +255,9 @@ def pluck(*fields)
255255
# @example Get the values in memory.
256256
# context.pick(:name)
257257
#
258-
# @param [ String | Symbol ] *fields Field(s) to pick.
258+
# @param [ [ String | Symbol ]... ] *fields Field(s) to pick.
259259
#
260-
# @return [ Object, Array<Object> ] The picked values.
260+
# @return [ Object | Array<Object> ] The picked values.
261261
def pick(*fields)
262262
if doc = documents.first
263263
pluck_from_doc(doc, *fields)
@@ -742,9 +742,9 @@ def retrieve_value_at_path(document, field_path)
742742
# Pluck the field values from the given document.
743743
#
744744
# @param [ Document ] doc The document to pluck from.
745-
# @param [ String | Symbol ] *fields Field(s) to pluck.
745+
# @param [ [ String | Symbol ]... ] *fields Field(s) to pluck.
746746
#
747-
# @return [ Object, Array<Object> ] The plucked values.
747+
# @return [ Object | Array<Object> ] The plucked values.
748748
def pluck_from_doc(doc, *fields)
749749
if fields.length == 1
750750
retrieve_value_at_path(doc, fields.first)

lib/mongoid/contextual/mongo.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def map_reduce(map, reduce)
321321
# @example Pluck a field.
322322
# context.pluck(:_id)
323323
#
324-
# @param [ String | Symbol ] *fields Field(s) to pluck,
324+
# @param [ [ String | Symbol ]... ] *fields Field(s) to pluck,
325325
# which may include nested fields using dot-notation.
326326
#
327327
# @return [ Array<Object> | Array<Array<Object>> ] The plucked values.
@@ -362,7 +362,7 @@ def pluck(*fields)
362362
# @example Pick a field.
363363
# context.pick(:_id)
364364
#
365-
# @param [ String | Symbol ] *fields Field(s) to pick.
365+
# @param [ [ String | Symbol ]... ] *fields Field(s) to pick.
366366
#
367367
# @return [ Object | Array<Object> ] The picked values.
368368
def pick(*fields)
@@ -519,7 +519,7 @@ def sort(values = nil, &block)
519519
# @option opts [ Array ] :array_filters A set of filters specifying to which array elements
520520
# an update should apply.
521521
#
522-
# @return [ nil, false ] False if no attributes were provided.
522+
# @return [ nil | false ] False if no attributes were provided.
523523
def update(attributes = nil, opts = {})
524524
update_documents(attributes, :update_one, opts)
525525
end
@@ -535,7 +535,7 @@ def update(attributes = nil, opts = {})
535535
# @option opts [ Array ] :array_filters A set of filters specifying to which array elements
536536
# an update should apply.
537537
#
538-
# @return [ nil, false ] False if no attributes were provided.
538+
# @return [ nil | false ] False if no attributes were provided.
539539
def update_all(attributes = nil, opts = {})
540540
update_documents(attributes, :update_many, opts)
541541
end

lib/mongoid/contextual/none.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def exists?; false; end
8888
# @example Get the values for null context.
8989
# context.pluck(:name)
9090
#
91-
# @param [ String | Symbol ] *_fields Field(s) to pluck.
91+
# @param [ [ String | Symbol ]... ] *_fields Field(s) to pluck.
9292
#
9393
# @return [ Array ] An empty Array.
9494
def pluck(*_fields)
@@ -100,9 +100,9 @@ def pluck(*_fields)
100100
# @example Get the value for null context.
101101
# context.pick(:name)
102102
#
103-
# @param [ String | Symbol ] *_fields Field or fields to pick.
103+
# @param [ [ String | Symbol ]... ] *_fields Field(s) to pick.
104104
#
105-
# @return [ nil ] Always reeturn nil.
105+
# @return [ nil ] Always return nil.
106106
def pick(*_fields)
107107
nil
108108
end

lib/mongoid/criteria.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def ==(other)
8888
# @example Tries to find a document whose _id is the stringification of the provided Proc, typically failing.
8989
# enumerator = criteria.find(-> { "Default Band" })
9090
#
91-
# @param [ Object | Array<Object> ] *args The ids.
91+
# @param [ [ Object | Array<Object> ]... ] *args The id(s).
9292
# @param [ Proc ] block Optional block to pass.
9393
#
9494
# @return [ Document | Array<Document> | nil ] A document or matching documents.
@@ -284,7 +284,7 @@ def empty_and_chainable?
284284
# @example Limit the fields returned from the database.
285285
# Band.only(:name)
286286
#
287-
# @param [ Array<Symbol> ] args The names of the fields.
287+
# @param [ [ Symbol | Array<Symbol> ]... ] *args The field name(s).
288288
#
289289
# @return [ Criteria ] The cloned criteria.
290290
def only(*args)
@@ -318,7 +318,7 @@ def read(value = nil)
318318
# @example Exclude fields returned from the database.
319319
# Band.without(:name)
320320
#
321-
# @param [ Array<Symbol> ] args The names of the fields.
321+
# @param [ Symbol... ] *args The field name(s).
322322
#
323323
# @return [ Criteria ] The cloned criteria.
324324
def without(*args)
@@ -385,7 +385,8 @@ def type(types)
385385
# @example Add a javascript selection.
386386
# criteria.where("this.name == 'syd'")
387387
#
388-
# @param [ String | Hash ] expression The javascript or standard selection.
388+
# @param [ [ Hash | String ]... ] *args The standard selection
389+
# or javascript string.
389390
#
390391
# @raise [ UnsupportedJavascript ] If provided a string and the criteria
391392
# is embedded.
@@ -495,7 +496,7 @@ def initialize_copy(other)
495496
# criteria.method_missing(:name)
496497
#
497498
# @param [ Symbol ] name The method name.
498-
# @param [ Array ] args The arguments.
499+
# @param [ Object... ] *args The arguments.
499500
#
500501
# @return [ Object ] The result of the method call.
501502
ruby2_keywords def method_missing(name, *args, &block)

lib/mongoid/criteria/findable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def execute_or_raise(ids, multi)
2121
multi ? result : result.first
2222
end
2323

24-
# Find the matchind document(s) in the criteria for the provided ids.
24+
# Find the matching document(s) in the criteria for the provided id(s).
2525
#
2626
# @note Each argument can be an individual id, an array of ids or
2727
# a nested array. Each array will be flattened.
@@ -32,7 +32,7 @@ def execute_or_raise(ids, multi)
3232
# @example Find by multiple ids.
3333
# criteria.find([ BSON::ObjectId.new, BSON::ObjectId.new ])
3434
#
35-
# @param [ Object | Array<Object> ] *args The ids to search for.
35+
# @param [ [ Object | Array<Object> ]... ] *args The id(s) to find.
3636
#
3737
# @return [ Document | Array<Document> ] The matching document(s).
3838
def find(*args)

lib/mongoid/criteria/includable.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ module Includable
2121
# @example Eager load the provided associations.
2222
# Person.includes(:posts, :game)
2323
#
24-
# @param [ Array<Symbol>, Array<Hash> ] relations The names of the associations to eager
25-
# load.
24+
# @param [ [ Symbol | Hash ]... ] *relations The names of the association(s)
25+
# to eager load.
2626
#
2727
# @return [ Criteria ] The cloned criteria.
2828
def includes(*relations)
@@ -70,7 +70,8 @@ def add_inclusion(association, parent = nil)
7070
# association originates.
7171
# @param [ String ] parent The name of the association above this one in
7272
# the inclusion tree, if it is a nested inclusion.
73-
# @param relations_list The names of the associations to eager load.
73+
# @param [ [ Symbol | Hash | Array<Symbol | Hash> ]... ] *relations_list
74+
# The names of the association(s) to eager load.
7475
def extract_includes_list(_parent_class, parent, *relations_list)
7576
relations_list.flatten.each do |relation_object|
7677
if relation_object.is_a?(Hash)

0 commit comments

Comments
 (0)