Skip to content

Commit 4f8f922

Browse files
johnnyshieldsp
andauthored
MONGOID-5415: Code docs: denote type unions with pipe (#5366)
* Docs--convert to pipe * More progress * Fix return values * More missed values * More missed items * Boolean --> true/false * Update matcher.rb * Oops * Update selectable.rb * Fix tuple * Fix tuple * Missed one * Revert splat * Revert array tuple * Revert Array tuple * - More array tuples - Remove trailing empty comment lines - Misc fixes * Whitespace * Update regexp.rb * fix serializable_hash * fix find * revert misadditions * redo extract_attribute note Co-authored-by: shields <[email protected]> Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent c74a931 commit 4f8f922

File tree

133 files changed

+450
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+450
-437
lines changed

lib/mongoid/association.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module Association
5656
# @example Is the document embedded?
5757
# address.embedded?
5858
#
59-
# @return [ true, false ] True if the document has a parent document.
59+
# @return [ true | false ] True if the document has a parent document.
6060
def embedded?
6161
@embedded ||= (cyclic ? _parent.present? : self.class.embedded?)
6262
end
@@ -66,7 +66,7 @@ def embedded?
6666
# @example Is the document in an embeds many?
6767
# address.embedded_many?
6868
#
69-
# @return [ true, false ] True if in an embeds many.
69+
# @return [ true | false ] True if in an embeds many.
7070
def embedded_many?
7171
_association && _association.is_a?(Association::Embedded::EmbedsMany)
7272
end
@@ -76,7 +76,7 @@ def embedded_many?
7676
# @example Is the document in an embeds one?
7777
# address.embedded_one?
7878
#
79-
# @return [ true, false ] True if in an embeds one.
79+
# @return [ true | false ] True if in an embeds one.
8080
def embedded_one?
8181
_association && _association.is_a?(Association::Embedded::EmbedsOne)
8282
end
@@ -100,7 +100,7 @@ def association_name
100100
# @example Is the document in a references many?
101101
# post.referenced_many?
102102
#
103-
# @return [ true, false ] True if in a references many.
103+
# @return [ true | false ] True if in a references many.
104104
def referenced_many?
105105
_association && _association.is_a?(Association::Referenced::HasMany)
106106
end
@@ -110,7 +110,7 @@ def referenced_many?
110110
# @example Is the document in a references one?
111111
# address.referenced_one?
112112
#
113-
# @return [ true, false ] True if in a references one.
113+
# @return [ true | false ] True if in a references one.
114114
def referenced_one?
115115
_association && _association.is_a?(Association::Referenced::HasOne)
116116
end

lib/mongoid/association/accessors.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ module Accessors
1515
# @example Build the association.
1616
# person.__build__(:addresses, { :_id => 1 }, association)
1717
#
18-
# @param [ String, Symbol ] name The name of the association.
19-
# @param [ Hash, BSON::ObjectId ] object The id or attributes to use.
18+
# @param [ String | Symbol ] name The name of the association.
19+
# @param [ Hash | BSON::ObjectId ] object The id or attributes to use.
2020
# @param [ Association ] association The association metadata.
2121
# @param [ Hash ] selected_fields Fields which were retrieved via #only.
2222
# If selected_fields is specified, fields not listed in it will not be
@@ -33,7 +33,7 @@ def __build__(name, object, association, selected_fields = nil)
3333
# @example Create the association.
3434
# person.create_relation(document, association)
3535
#
36-
# @param [ Document, Array<Document> ] object The association target.
36+
# @param [ Document | Array<Document> ] object The association target.
3737
# @param [ Association ] association The association metadata.
3838
# @param [ Hash ] selected_fields Fields which were retrieved via #only.
3939
# If selected_fields is specified, fields not listed in it will not be
@@ -80,7 +80,7 @@ def reset_relation_criteria(name)
8080
# @example Set the proxy on the document.
8181
# person.set(:addresses, addresses)
8282
#
83-
# @param [ String, Symbol ] name The name of the association.
83+
# @param [ String | Symbol ] name The name of the association.
8484
# @param [ Proxy ] relation The association to set.
8585
#
8686
# @return [ Proxy ] The association.
@@ -101,7 +101,7 @@ def set_relation(name, relation)
101101
# @param [ Symbol ] name The name of the association.
102102
# @param [ Association ] association The association metadata.
103103
# @param [ Object ] object The object used to build the association.
104-
# @param [ true, false ] reload If the association is to be reloaded.
104+
# @param [ true | false ] reload If the association is to be reloaded.
105105
#
106106
# @return [ Proxy ] The association.
107107
def get_relation(name, association, object, reload = false)
@@ -225,7 +225,7 @@ def needs_no_database_query?(object, association)
225225
# @example Is autobuild disabled?
226226
# document.without_autobuild?
227227
#
228-
# @return [ true, false ] If autobuild is disabled.
228+
# @return [ true | false ] If autobuild is disabled.
229229
def without_autobuild?
230230
Threaded.executing?(:without_autobuild)
231231
end

lib/mongoid/association/bindable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Bindable
1515
# Binding.new(base, target, association)
1616
#
1717
# @param [ Document ] base The base of the binding.
18-
# @param [ Document, Array<Document> ] target The target of the binding.
18+
# @param [ Document | Array<Document> ] target The target of the binding.
1919
# @param [ Association ] association The association metadata.
2020
def initialize(base, target, association)
2121
@_base, @_target, @_association = base, target, association
@@ -200,7 +200,7 @@ def record_id(_base)
200200
# @example Set the base association.
201201
# binding.set_base_association
202202
#
203-
# @return [ true, false ] If the association changed.
203+
# @return [ true | false ] If the association changed.
204204
def set_base_association
205205
inverse_association = _association.inverse_association(_target)
206206
if inverse_association != _association && !inverse_association.nil?

lib/mongoid/association/constrainable.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module Association
55

66
# Used for converting foreign key values to the correct type based on the
77
# types of ids that the document stores.
8-
#
98
module Constrainable
109

1110
# Convert the supplied object to the appropriate type to set as the

lib/mongoid/association/embedded/batchable.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def execute_batch_push(docs)
196196
# @example Can inserts be performed?
197197
# batchable.insertable?
198198
#
199-
# @return [ true, false ] If inserts can be performed.
199+
# @return [ true | false ] If inserts can be performed.
200200
def insertable?
201201
persistable? && !_assigning? && inserts_valid
202202
end
@@ -208,7 +208,7 @@ def insertable?
208208
# @example Are the inserts currently valid.
209209
# batchable.inserts_valid
210210
#
211-
# @return [ true, false ] If inserts are currently valid.
211+
# @return [ true | false ] If inserts are currently valid.
212212
def inserts_valid
213213
@inserts_valid
214214
end
@@ -220,9 +220,9 @@ def inserts_valid
220220
# @example Set the flag.
221221
# batchable.inserts_valid = true
222222
#
223-
# @param [ true, false ] value The flag.
223+
# @param [ true | false ] value The flag.
224224
#
225-
# @return [ true, false ] The flag.
225+
# @return [ true | false ] The flag.
226226
def inserts_valid=(value)
227227
@inserts_valid = value
228228
end
@@ -235,7 +235,7 @@ def inserts_valid=(value)
235235
# @example Normalize the docs.
236236
# batchable.normalize_docs(docs)
237237
#
238-
# @param [ Array<Hash, Document> ] docs The docs to normalize.
238+
# @param [ Array<Hash | Document> ] docs The docs to normalize.
239239
#
240240
# @return [ Array<Document> ] The docs.
241241
def normalize_docs(docs)

lib/mongoid/association/embedded/cyclic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def cyclic_parent_name
8888
# @example Determine the child name.
8989
# Role.cyclic_child_name
9090
#
91-
# @param [ true, false ] many Is the a many association?
91+
# @param [ true | false ] many Is the a many association?
9292
#
9393
# @return [ String ] "child_" plus the class name underscored in
9494
# singular or plural form.

lib/mongoid/association/embedded/embedded_in.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def relation
7575

7676
# Is this association polymorphic?
7777
#
78-
# @return [ true, false ] Whether this association is polymorphic.
78+
# @return [ true | false ] Whether this association is polymorphic.
7979
def polymorphic?
8080
!!@options[:polymorphic]
8181
end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def initialize(base, target, association)
3232
#
3333
# @param [ Document ] replacement A document to replace the target.
3434
#
35-
# @return [ Document, nil ] The association or nil.
35+
# @return [ Document | nil ] The association or nil.
3636
def substitute(replacement)
3737
unbind_one
3838
unless replacement
@@ -74,7 +74,7 @@ def characterize_one(document)
7474
# @example Can we persist the association?
7575
# relation.persistable?
7676
#
77-
# @return [ true, false ] If the association is persistable.
77+
# @return [ true | false ] If the association is persistable.
7878
def persistable?
7979
_target.persisted? && !_binding? && !_building?
8080
end

lib/mongoid/association/embedded/embeds_many.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def relation
9292

9393
# Is this association polymorphic?
9494
#
95-
# @return [ true, false ] Whether this association is polymorphic.
95+
# @return [ true | false ] Whether this association is polymorphic.
9696
def polymorphic?
9797
@polymorphic ||= !!@options[:as]
9898
end
@@ -101,7 +101,7 @@ def polymorphic?
101101
#
102102
# @note Only relevant if the association is polymorphic.
103103
#
104-
# @return [ String, nil ] The field for storing the associated object's type.
104+
# @return [ String | nil ] The field for storing the associated object's type.
105105
def type
106106
@type ||= "#{as}_type" if polymorphic?
107107
end

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

Lines changed: 10 additions & 10 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 | Array<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 | Array<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.
@@ -135,7 +135,7 @@ def count(*args, &block)
135135
#
136136
# @param [ Document ] document The document to be deleted.
137137
#
138-
# @return [ Document, nil ] The deleted document or nil if nothing deleted.
138+
# @return [ Document | nil ] The deleted document or nil if nothing deleted.
139139
def delete(document)
140140
execute_callbacks_around(:remove, document) do
141141
doc = _target.delete_one(document)
@@ -176,7 +176,7 @@ def delete_all(conditions = {})
176176
# doc.state == "GA"
177177
# end
178178
#
179-
# @return [ Many, Enumerator ] The association or an enumerator if no
179+
# @return [ Many | Enumerator ] The association or an enumerator if no
180180
# block was provided.
181181
def delete_if
182182
if block_given?
@@ -210,7 +210,7 @@ def destroy_all(conditions = {})
210210
# @example Are there persisted documents?
211211
# person.posts.exists?
212212
#
213-
# @return [ true, false ] True is persisted documents exist, false if not.
213+
# @return [ true | false ] True is persisted documents exist, false if not.
214214
def exists?
215215
_target.any? { |doc| doc.persisted? }
216216
end
@@ -287,7 +287,7 @@ def in_memory
287287
# @param [ Integer ] count The number of documents to pop, or 1 if not
288288
# provided.
289289
#
290-
# @return [ Document, Array<Document> ] The popped document(s).
290+
# @return [ Document | Array<Document> ] The popped document(s).
291291
def pop(count = nil)
292292
if count
293293
if docs = _target[_target.size - count, _target.size]
@@ -312,7 +312,7 @@ def pop(count = nil)
312312
# @param [ Integer ] count The number of documents to shift, or 1 if not
313313
# provided.
314314
#
315-
# @return [ Document, Array<Document> ] The shifted document(s).
315+
# @return [ Document | Array<Document> ] The shifted document(s).
316316
def shift(count = nil)
317317
if count
318318
if _target.size > 0 && docs = _target[0, count]
@@ -429,7 +429,7 @@ def integrate(document)
429429
#
430430
# If the method exists on the array, use the default proxy behavior.
431431
#
432-
# @param [ Symbol, String ] name The name of the method.
432+
# @param [ Symbol | String ] name The name of the method.
433433
# @param [ Array ] args The method args
434434
# @param [ Proc ] block Optional block to pass.
435435
#
@@ -446,7 +446,7 @@ def integrate(document)
446446
# @example Can we persist the association?
447447
# relation.persistable?
448448
#
449-
# @return [ true, false ] If the association is persistable.
449+
# @return [ true | false ] If the association is persistable.
450450
def persistable?
451451
_base.persisted? && !_binding?
452452
end
@@ -490,7 +490,7 @@ def scope(docs)
490490
# relation.remove_all({ :num => 1 }, true)
491491
#
492492
# @param [ Hash ] conditions Conditions to filter by.
493-
# @param [ true, false ] method :delete or :destroy.
493+
# @param [ true | false ] method :delete or :destroy.
494494
#
495495
# @return [ Integer ] The number of documents removed.
496496
def remove_all(conditions = {}, method = :delete)

0 commit comments

Comments
 (0)