diff --git a/README.md b/README.md index 9db5f214c..3e5481f04 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ All new versions will undergo battle-testing in production at TableCheck prior t - ✅ Use a publicly visible CI (Github Actions) as the primary CI. Remove Evergreen CI. - ✅ Remove MRSS submodules and other MongoDB corporate baloney. - ✅ [MONGOID-5570](https://jira.mongodb.org/browse/MONGOID-5570) - Code Docs: Ensure 100% documentation coverage, enforced with Rubocop. +- ✅ [MONGOID-5564](https://jira.mongodb.org/browse/MONGOID-5564) - Code Docs: Use full namespaces in docs. - More to come soon! ## Documentation diff --git a/docs/contributing/code-documentation.txt b/docs/contributing/code-documentation.txt index 9713ce278..01d087e29 100644 --- a/docs/contributing/code-documentation.txt +++ b/docs/contributing/code-documentation.txt @@ -149,6 +149,31 @@ Formatting Type Declaration ---------------- +- **Namespaces:** Always use fully-namespaced class/module names. + Do not use leading colons ``::``. + + .. code-block:: ruby + + # GOOD: + # @param [ ActiveSupport::TimeWithZone ] time Time for alarm. + + # BAD: + # @param [ TimeWithZone ] time Time for alarm. + # @param [ ::ActiveSupport::TimeWithZone ] time Time for alarm. + +- **Module Types:** It is acceptable to reference types by a module + which they include. + + .. code-block:: ruby + + class Person + include ActiveModel::Model + end + + # @param [ ActiveModel::Model ] model Any object whose class + # includes ActiveModel::Model. An instance of Person would + # be acceptable here. + - **Type Unions:** Use pipe ``|`` to denote a union of allowed types. .. code-block:: ruby diff --git a/lib/mongoid/association/accessors.rb b/lib/mongoid/association/accessors.rb index e0e4bd672..fdfdb54d6 100644 --- a/lib/mongoid/association/accessors.rb +++ b/lib/mongoid/association/accessors.rb @@ -22,7 +22,7 @@ module Accessors # If selected_fields is specified, fields not listed in it will not be # accessible in the built document. # - # @return [ Proxy ] The association. + # @return [ Mongoid::Association::Proxy ] The association. def __build__(name, object, association, selected_fields = nil) relation = create_relation(object, association, selected_fields) set_relation(name, relation) @@ -33,13 +33,13 @@ def __build__(name, object, association, selected_fields = nil) # @example Create the association. # person.create_relation(document, association) # - # @param [ Document | Array ] object The association target. + # @param [ Mongoid::Document | Array ] object The association target. # @param [ Mongoid::Association::Relatable ] association The association metadata. # @param [ Hash ] selected_fields Fields which were retrieved via #only. # If selected_fields is specified, fields not listed in it will not be # accessible in the created association document. # - # @return [ Proxy ] The association. + # @return [ Mongoid::Association::Proxy ] The association. def create_relation(object, association, selected_fields = nil) type = @attributes[association.inverse_type] target = if t = association.build(self, object, type, selected_fields) @@ -81,9 +81,9 @@ def reset_relation_criteria(name) # person.set(:addresses, addresses) # # @param [ String | Symbol ] name The name of the association. - # @param [ Proxy ] relation The association to set. + # @param [ Mongoid::Association::Proxy ] relation The association to set. # - # @return [ Proxy ] The association. + # @return [ Mongoid::Association::Proxy ] The association. def set_relation(name, relation) instance_variable_set("@_#{name}", relation) end @@ -103,7 +103,7 @@ def set_relation(name, relation) # @param [ Object ] object The object used to build the association. # @param [ true | false ] reload If the association is to be reloaded. # - # @return [ Proxy ] The association. + # @return [ Mongoid::Association::Proxy ] The association. def get_relation(name, association, object, reload = false) field_name = database_field_name(name) diff --git a/lib/mongoid/association/bindable.rb b/lib/mongoid/association/bindable.rb index d578102bf..e4105513b 100644 --- a/lib/mongoid/association/bindable.rb +++ b/lib/mongoid/association/bindable.rb @@ -14,8 +14,8 @@ module Bindable # @example Initialize a binding. # Binding.new(base, target, association) # - # @param [ Document ] base The base of the binding. - # @param [ Document | Array ] target The target of the binding. + # @param [ Mongoid::Document ] base The base of the binding. + # @param [ Mongoid::Document | Array ] target The target of the binding. # @param [ Mongoid::Association::Relatable ] association The association metadata. def initialize(base, target, association) @_base, @_target, @_association = base, target, association @@ -46,7 +46,7 @@ def binding # @example Check the inverse definition. # binding.check_inverse!(doc) # - # @param [ Document ] doc The document getting bound. + # @param [ Mongoid::Document ] doc The document getting bound. # # @raise [ Errors::InverseNotFound ] If no inverse found. def check_inverse!(doc) @@ -62,7 +62,7 @@ def check_inverse!(doc) # Remove the associated document from the inverse's association. # - # @param [ Document ] doc The document to remove. + # @param [ Mongoid::Document ] doc The document to remove. def remove_associated(doc) if inverse = _association.inverse(doc) if _association.many? @@ -77,7 +77,7 @@ def remove_associated(doc) # # This method removes the associated on *_many relationships. # - # @param [ Document ] doc The document to remove. + # @param [ Mongoid::Document ] doc The document to remove. # @param [ Symbol ] inverse The name of the inverse. def remove_associated_many(doc, inverse) # We only want to remove the inverse association when the inverse @@ -97,7 +97,7 @@ def remove_associated_many(doc, inverse) # This method removes associated on belongs_to and embedded_in # associations. # - # @param [ Document ] doc The document to remove. + # @param [ Mongoid::Document ] doc The document to remove. # @param [ Symbol ] inverse The name of the inverse. def remove_associated_in_to(doc, inverse) # We only want to remove the inverse association when the inverse @@ -115,7 +115,7 @@ def remove_associated_in_to(doc, inverse) # @example Bind the foreign key. # binding.bind_foreign_key(post, person._id) # - # @param [ Document ] keyed The document that stores the foreign key. + # @param [ Mongoid::Document ] keyed The document that stores the foreign key. # @param [ Object ] id The id of the bound document. def bind_foreign_key(keyed, id) unless keyed.frozen? @@ -131,7 +131,7 @@ def bind_foreign_key(keyed, id) # @example Bind the polymorphic type. # binding.bind_polymorphic_type(post, "Person") # - # @param [ Document ] typed The document that stores the type field. + # @param [ Mongoid::Document ] typed The document that stores the type field. # @param [ String ] name The name of the model. def bind_polymorphic_type(typed, name) if _association.type @@ -147,7 +147,7 @@ def bind_polymorphic_type(typed, name) # @example Bind the polymorphic type. # binding.bind_polymorphic_inverse_type(post, "Person") # - # @param [ Document ] typed The document that stores the type field. + # @param [ Mongoid::Document ] typed The document that stores the type field. # @param [ String ] name The name of the model. def bind_polymorphic_inverse_type(typed, name) if _association.inverse_type @@ -163,8 +163,8 @@ def bind_polymorphic_inverse_type(typed, name) # @example Bind the inverse. # binding.bind_inverse(post, person) # - # @param [ Document ] doc The base document. - # @param [ Document ] inverse The inverse document. + # @param [ Mongoid::Document ] doc The base document. + # @param [ Mongoid::Document ] inverse The inverse document. def bind_inverse(doc, inverse) if doc.respond_to?(_association.inverse_setter) doc.you_must(_association.inverse_setter, inverse) @@ -178,7 +178,7 @@ def bind_inverse(doc, inverse) # @example Bind the document with the base. # binding.bind_from_relational_parent(doc) # - # @param [ Document ] doc The document to bind. + # @param [ Mongoid::Document ] doc The document to bind. def bind_from_relational_parent(doc) check_inverse!(doc) remove_associated(doc) @@ -215,7 +215,7 @@ def set_base_association # @example Bind the document with the base. # unbinding.unbind_from_relational_parent(doc) # - # @param [ Document ] doc The document to unbind. + # @param [ Mongoid::Document ] doc The document to unbind. def unbind_from_relational_parent(doc) check_inverse!(doc) bind_foreign_key(doc, nil) diff --git a/lib/mongoid/association/embedded/batchable.rb b/lib/mongoid/association/embedded/batchable.rb index ee30ca2de..aed70e356 100644 --- a/lib/mongoid/association/embedded/batchable.rb +++ b/lib/mongoid/association/embedded/batchable.rb @@ -16,7 +16,7 @@ module Batchable # @example Execute the batch push. # batchable.batch_insert([ doc_one, doc_two ]) # - # @param [ Array ] docs The docs to add. + # @param [ Array ] docs The docs to add. # # @return [ Array ] The inserts. def batch_insert(docs) @@ -28,7 +28,7 @@ def batch_insert(docs) # @example Clear all docs. # batchable.batch_clear(docs) # - # @param [ Array ] docs The docs to clear. + # @param [ Array ] docs The docs to clear. # # @return [ Array ] The empty array. def batch_clear(docs) @@ -53,7 +53,7 @@ def batch_clear(docs) # @example Batch remove the documents. # batchable.batch_remove([ doc_one, doc_two ]) # - # @param [ Array ] docs The docs to remove. + # @param [ Array ] docs The docs to remove. # @param [ Symbol ] method Delete or destroy. def batch_remove(docs, method = :delete) # If the _id is nil, we cannot use $pull and delete by searching for @@ -95,7 +95,7 @@ def batch_remove(docs, method = :delete) # @example Batch replace the documents. # batchable.batch_replace([ doc_one, doc_two ]) # - # @param [ Array | Array ] docs The docs to replace with. + # @param [ Array | Array ] docs The docs to replace with. # # @return [ Array ] The inserts. def batch_replace(docs) @@ -148,7 +148,7 @@ def add_atomic_sets(sets) # @example Perform a batch $set. # batchable.execute_batch_set(docs) # - # @param [ Array ] docs The docs to persist. + # @param [ Array ] docs The docs to persist. # # @return [ Array ] The inserts. def execute_batch_set(docs) @@ -171,7 +171,7 @@ def execute_batch_set(docs) # @example Perform a batch push. # batchable.execute_batch_push(docs) # - # @param [ Array ] docs The docs to persist. + # @param [ Array ] docs The docs to persist. # # @return [ Array ] The inserts. def execute_batch_push(docs) @@ -233,9 +233,9 @@ def inserts_valid=(value) # @example Normalize the docs. # batchable.normalize_docs(docs) # - # @param [ Array | Array ] docs The docs to normalize. + # @param [ Array | Array ] docs The docs to normalize. # - # @return [ Array ] The docs. + # @return [ Array ] The docs. def normalize_docs(docs) if docs.first.is_a?(::Hash) docs.map do |doc| @@ -308,7 +308,7 @@ def selector # @example Pre process the documents. # batchable.pre_process_batch_insert(docs) # - # @param [ Array ] docs The documents. + # @param [ Array ] docs The documents. # # @return [ Array ] The documents as an array of hashes. def pre_process_batch_insert(docs) @@ -334,7 +334,7 @@ def pre_process_batch_insert(docs) # @example Pre process the documents. # batchable.pre_process_batch_remove(docs, :delete) # - # @param [ Array ] docs The documents. + # @param [ Array ] docs The documents. # @param [ Symbol ] method Delete or destroy. # # @return [ Array ] The documents as hashes. @@ -361,7 +361,7 @@ def pre_process_batch_remove(docs, method) # @example Post process the documents. # batchable.post_process_batch_insert(docs) # - # @param [ Array ] docs The inserted docs. + # @param [ Array ] docs The inserted docs. # # @return [ Enumerable ] The document enum. def post_process_batch_insert(docs) @@ -379,10 +379,10 @@ def post_process_batch_insert(docs) # @example Post process the documents. # batchable.post_process_batch_remove(docs, :delete) # - # @param [ Array ] docs The documents. + # @param [ Array ] docs The documents. # @param [ Symbol ] method Delete or destroy. # - # @return [ Array ] The documents. + # @return [ Array ] The documents. def post_process_batch_remove(docs, method) docs.each do |doc| doc.run_after_callbacks(:destroy) if method == :destroy diff --git a/lib/mongoid/association/embedded/embedded_in/binding.rb b/lib/mongoid/association/embedded/embedded_in/binding.rb index c4bb3799e..111240023 100644 --- a/lib/mongoid/association/embedded/embedded_in/binding.rb +++ b/lib/mongoid/association/embedded/embedded_in/binding.rb @@ -57,7 +57,7 @@ def unbind_one # @example Check for inverses errors. # binding.check_inverses!(doc) # - # @param [ Document ] doc The document to check. + # @param [ Mongoid::Document ] doc The document to check. def check_polymorphic_inverses!(doc) if inverses = _association.inverses(doc) if inverses.length > 1 diff --git a/lib/mongoid/association/embedded/embedded_in/buildable.rb b/lib/mongoid/association/embedded/embedded_in/buildable.rb index 15c67bc1b..9f646b298 100644 --- a/lib/mongoid/association/embedded/embedded_in/buildable.rb +++ b/lib/mongoid/association/embedded/embedded_in/buildable.rb @@ -15,14 +15,14 @@ module Buildable # @example Build the document. # Builder.new(meta, attrs).build # - # @param [ Document ] base The object. - # @param [ Document | Hash ] object The parent hash or document. + # @param [ Mongoid::Document ] base The object. + # @param [ Mongoid::Document | Hash ] object The parent hash or document. # @param [ String ] type Not used in this context. # @param [ Hash ] selected_fields Fields which were retrieved via # #only. If selected_fields are specified, fields not listed in it # will not be accessible in the built document. # - # @return [ Document ] A single document. + # @return [ Mongoid::Document ] A single document. def build(base, object, type = nil, selected_fields = nil) return object unless object.is_a?(Hash) if _loading? diff --git a/lib/mongoid/association/embedded/embedded_in/proxy.rb b/lib/mongoid/association/embedded/embedded_in/proxy.rb index 8fda9b19d..f81d8a187 100644 --- a/lib/mongoid/association/embedded/embedded_in/proxy.rb +++ b/lib/mongoid/association/embedded/embedded_in/proxy.rb @@ -18,8 +18,8 @@ class Proxy < Association::One # @example Create the new association. # Association::Embedded::EmbeddedIn.new(person, address, association) # - # @param [ Document ] base The document the association hangs off of. - # @param [ Document ] target The target (parent) of the association. + # @param [ Mongoid::Document ] base The document the association hangs off of. + # @param [ Mongoid::Document ] target The target (parent) of the association. # @param [ Mongoid::Association::Relatable ] association The association metadata. # # @return [ In ] The proxy. @@ -36,9 +36,9 @@ def initialize(base, target, association) # @example Substitute the new document. # person.name.substitute(new_name) # - # @param [ Document | Hash ] replacement A document to replace the target. + # @param [ Mongoid::Document | Hash ] replacement A document to replace the target. # - # @return [ Document | nil ] The association or nil. + # @return [ Mongoid::Document | nil ] The association or nil. def substitute(replacement) unbind_one unless replacement @@ -69,7 +69,7 @@ def binding # @example Set the base association. # object.characterize_one(document) # - # @param [ Document ] document The document to set the association metadata on. + # @param [ Mongoid::Document ] document The document to set the association metadata on. def characterize_one(document) unless _base._association _base._association = _association.inverse_association(document) @@ -94,7 +94,7 @@ class << self # @param [ Array ] docs The parent documents # that possess the given associations, which ought to be # populated by the eager-loaded documents. - # + # # @return [ Mongoid::Association::Embedded::Eager ] def eager_loader(associations, docs) Eager.new(associations, docs) @@ -116,7 +116,7 @@ def embedded? # @example Get the path calculator. # Proxy.path(document) # - # @param [ Document ] document The document to calculate on. + # @param [ Mongoid::Document ] document The document to calculate on. # # @return [ Root ] The root atomic path calculator. def path(document) diff --git a/lib/mongoid/association/embedded/embeds_many.rb b/lib/mongoid/association/embedded/embeds_many.rb index 1cfacacf7..c2e176e30 100644 --- a/lib/mongoid/association/embedded/embeds_many.rb +++ b/lib/mongoid/association/embedded/embeds_many.rb @@ -121,7 +121,7 @@ def nested_builder(attributes, options) # @example Get the path calculator. # Proxy.path(document) # - # @param [ Document ] document The document to calculate on. + # @param [ Mongoid::Document ] document The document to calculate on. # # @return [ Mongoid::Atomic::Paths::Embedded::Many ] # The embedded many atomic path calculator. @@ -131,8 +131,8 @@ def path(document) # Get a criteria object for searching given a parent and children documents. # - # @param [ Document ] base The base document. - # @param [ Document ] target The children documents. + # @param [ Mongoid::Document ] base The base document. + # @param [ Mongoid::Document ] target The children documents. def criteria(base, target) criterion = klass.scoped criterion.embedded = true diff --git a/lib/mongoid/association/embedded/embeds_many/binding.rb b/lib/mongoid/association/embedded/embeds_many/binding.rb index eeeef2596..ac895b0b4 100644 --- a/lib/mongoid/association/embedded/embeds_many/binding.rb +++ b/lib/mongoid/association/embedded/embeds_many/binding.rb @@ -15,7 +15,7 @@ class Binding # @example Bind one document. # person.addresses.bind_one(address) # - # @param [ Document ] doc The single document to bind. + # @param [ Mongoid::Document ] doc The single document to bind. def bind_one(doc) doc.parentize(_base) binding do @@ -29,7 +29,7 @@ def bind_one(doc) # @example Unbind the document. # person.addresses.unbind_one(document) # - # @param [ Document ] doc The single document to unbind. + # @param [ Mongoid::Document ] doc The single document to unbind. def unbind_one(doc) binding do doc.do_or_do_not(_association.inverse_setter(_target), nil) diff --git a/lib/mongoid/association/embedded/embeds_many/buildable.rb b/lib/mongoid/association/embedded/embeds_many/buildable.rb index 9c4b179c1..43c72927c 100644 --- a/lib/mongoid/association/embedded/embeds_many/buildable.rb +++ b/lib/mongoid/association/embedded/embeds_many/buildable.rb @@ -17,15 +17,15 @@ module Buildable # @example Build the documents. # Builder.new(meta, attrs).build # - # @param [ Document ] base The base object. - # @param [ Array | Array ] object The object to use + # @param [ Mongoid::Document ] base The base object. + # @param [ Array | Array ] object The object to use # to build the association. # @param [ String ] type Not used in this context. # @param [ Hash ] selected_fields Fields which were retrieved via # #only. If selected_fields are specified, fields not listed in it # will not be accessible in the built documents. # - # @return [ Array ] The documents. def build(base, object, type = nil, selected_fields = nil) return [] if object.blank? return object if object.first.is_a?(Document) diff --git a/lib/mongoid/association/embedded/embeds_many/proxy.rb b/lib/mongoid/association/embedded/embeds_many/proxy.rb index ae70abfdb..c5a690acc 100644 --- a/lib/mongoid/association/embedded/embeds_many/proxy.rb +++ b/lib/mongoid/association/embedded/embeds_many/proxy.rb @@ -25,7 +25,7 @@ class Proxy < Association::Many # @example Push a document. # person.addresses.push(address) # - # @param [ Document... ] *args Any number of documents. + # @param [ Mongoid::Document... ] *args Any number of documents. def <<(*args) docs = args.flatten return concat(docs) if docs.size > 1 @@ -54,9 +54,9 @@ def as_document # @example Concat with other documents. # person.addresses.concat([ address_one, address_two ]) # - # @param [ Array ] docs The docs to add. + # @param [ Array ] docs The docs to add. # - # @return [ Array ] The documents. + # @return [ Array ] The documents. def concat(docs) batch_insert(docs) unless docs.empty? self @@ -71,7 +71,7 @@ def concat(docs) # @param [ Hash ] attributes The attributes to build the document with. # @param [ Class ] type Optional class to build the document with. # - # @return [ Document ] The new document. + # @return [ Mongoid::Document ] The new document. def build(attributes = {}, type = nil) doc = Factory.execute_build(type || _association.klass, attributes, execute_callbacks: false) append(doc) @@ -139,9 +139,9 @@ def count(*args, &block) # @example Delete the document from the association. # person.addresses.delete(address) # - # @param [ Document ] document The document to be deleted. + # @param [ Mongoid::Document ] document The document to be deleted. # - # @return [ Document | nil ] The deleted document or nil if nothing deleted. + # @return [ Mongoid::Document | nil ] The deleted document or nil if nothing deleted. def delete(document) execute_callbacks_around(:remove, document) do doc = _target.delete_one(document) @@ -245,7 +245,7 @@ def exists? # @param &block Optional block to pass. # @yield [ Object ] Yields each enumerable element to the block. # - # @return [ Document | Array | nil ] A document or matching documents. + # @return [ Mongoid::Document | Array | nil ] A document or matching documents. def find(*args, &block) criteria.find(*args, &block) end @@ -255,8 +255,8 @@ def find(*args, &block) # @example Create the new association. # Many.new(person, addresses, association) # - # @param [ Document ] base The document this association hangs off of. - # @param [ Array ] target The child documents of the association. + # @param [ Mongoid::Document ] base The document this association hangs off of. + # @param [ Array ] target The child documents of the association. # @param [ Mongoid::Association::Relatable ] association The association metadata. # # @return [ Many ] The proxy. @@ -277,7 +277,7 @@ def initialize(base, target, association) # @example Get the in memory documents. # relation.in_memory # - # @return [ Array ] The documents in memory. + # @return [ Array ] The documents in memory. def in_memory _target end @@ -294,7 +294,7 @@ def in_memory # @param [ Integer ] count The number of documents to pop, or 1 if not # provided. # - # @return [ Document | Array ] The popped document(s). + # @return [ Mongoid::Document | Array ] The popped document(s). def pop(count = nil) if count if docs = _target[_target.size - count, _target.size] @@ -319,7 +319,7 @@ def pop(count = nil) # @param [ Integer ] count The number of documents to shift, or 1 if not # provided. # - # @return [ Document | Array ] The shifted document(s). + # @return [ Mongoid::Document | Array ] The shifted document(s). def shift(count = nil) if count if _target.size > 0 && docs = _target[0, count] @@ -338,7 +338,7 @@ def shift(count = nil) # @example Substitute the association's target. # person.addresses.substitute([ address ]) # - # @param [ Array | Array ] docs The replacement docs. + # @param [ Array | Array ] docs The replacement docs. # # @return [ Many ] The proxied association. def substitute(docs) @@ -353,7 +353,7 @@ def substitute(docs) # @example Get the unscoped documents. # person.addresses.unscoped # - # @return [ Criteria ] The unscoped association. + # @return [ Mongoid::Criteria ] The unscoped association. def unscoped criterion = klass.unscoped criterion.embedded = true @@ -373,7 +373,7 @@ def object_already_related?(document) # @example Append to the document. # relation.append(document) # - # @param [ Document ] document The document to append to the target. + # @param [ Mongoid::Document ] document The document to append to the target. def append(document) execute_callback :before_add, document unless object_already_related?(document) @@ -399,7 +399,7 @@ def binding # Returns the +Criteria+ object for the target class with its # documents set to the list of target documents in the association. # - # @return [ Criteria ] A new criteria. + # @return [ Mongoid::Criteria ] A new criteria. def criteria _association.criteria(_base, _target) end @@ -411,7 +411,7 @@ def criteria # @example Delete one document. # relation.delete_one(doc) # - # @param [ Document ] document The document to delete. + # @param [ Mongoid::Document ] document The document to delete. def delete_one(document) _target.delete_one(document) _unscoped.delete_one(document) @@ -425,7 +425,7 @@ def delete_one(document) # @example Integrate the document. # relation.integrate(document) # - # @param [ Document ] document The document to integrate. + # @param [ Mongoid::Document ] document The document to integrate. def integrate(document) characterize_one(document) bind_one(document) @@ -440,7 +440,7 @@ def integrate(document) # @param [ Object... ] *args The method args. # @param &block Optional block to pass. # - # @return [ Criteria | Object ] A Criteria or return value from the target. + # @return [ Mongoid::Criteria | Object ] A Criteria or return value from the target. ruby2_keywords def method_missing(name, *args, &block) return super if _target.respond_to?(name) klass.send(:with_scope, criteria) do @@ -476,9 +476,9 @@ def reindex # @example Apply scoping. # person.addresses.scope(target) # - # @param [ Array ] docs The documents to scope. + # @param [ Array ] docs The documents to scope. # - # @return [ Array ] The scoped docs. + # @return [ Array ] The scoped docs. def scope(docs) unless _association.order || _association.klass.default_scoping? return docs @@ -513,7 +513,7 @@ def remove_all(conditions = {}, method = :delete) # @example Get the unscoped documents. # relation._unscoped # - # @return [ Array ] The unscoped documents. + # @return [ Array ] The unscoped documents. def _unscoped @_unscoped ||= [] end @@ -523,9 +523,9 @@ def _unscoped # @example Set the unscoped documents. # relation._unscoped = docs # - # @param [ Array ] docs The documents. + # @param [ Array ] docs The documents. # - # @return [ Array ] The unscoped docs. def _unscoped=(docs) @_unscoped = docs end diff --git a/lib/mongoid/association/embedded/embeds_one/buildable.rb b/lib/mongoid/association/embedded/embeds_one/buildable.rb index 6ace79de0..fc186fae3 100644 --- a/lib/mongoid/association/embedded/embeds_one/buildable.rb +++ b/lib/mongoid/association/embedded/embeds_one/buildable.rb @@ -16,14 +16,14 @@ module Buildable # @example Build the document. # Builder.new(meta, attrs).build # - # @param [ Document ] base The document this association hangs off of. - # @param [ Document | Hash ] object The related document. + # @param [ Mongoid::Document ] base The document this association hangs off of. + # @param [ Mongoid::Document | Hash ] object The related document. # @param [ String ] _type Not used in this context. # @param [ Hash ] selected_fields Fields which were retrieved via # #only. If selected_fields are specified, fields not listed in it # will not be accessible in the built document. # - # @return [ Document ] A single document. + # @return [ Mongoid::Document ] A single document. def build(base, object, _type = nil, selected_fields = nil) if object.is_a?(Hash) if _loading? && base.persisted? diff --git a/lib/mongoid/association/embedded/embeds_one/proxy.rb b/lib/mongoid/association/embedded/embeds_one/proxy.rb index 981784f30..186c690f4 100644 --- a/lib/mongoid/association/embedded/embeds_one/proxy.rb +++ b/lib/mongoid/association/embedded/embeds_one/proxy.rb @@ -29,8 +29,8 @@ class Proxy < Association::One # @example Create the new proxy. # One.new(person, name, association) # - # @param [ Document ] base The document this association hangs off of. - # @param [ Document ] target The child document in the association. + # @param [ Mongoid::Document ] base The document this association hangs off of. + # @param [ Mongoid::Document ] target The child document in the association. # @param [ Mongoid::Association::Relatable ] association The association metadata. def initialize(base, target, association) init(base, target, association) do @@ -49,9 +49,9 @@ def initialize(base, target, association) # @example Substitute the new document. # person.name.substitute(new_name) # - # @param [ Document | Hash ] replacement A document to replace the target. + # @param [ Mongoid::Document | Hash ] replacement A document to replace the target. # - # @return [ Document | nil ] The association or nil. + # @return [ Mongoid::Document | nil ] The association or nil. def substitute(replacement) if replacement != self if _assigning? @@ -132,7 +132,7 @@ def persistable? # Update the _base's attributes hash with the _target's attributes # - # @param replacement [ Document | nil ] The doc to use to update the + # @param replacement [ Mongoid::Document | nil ] The doc to use to update the # attributes hash. # # @api private @@ -174,7 +174,7 @@ def embedded? # @example Get the path calculator. # Proxy.path(document) # - # @param [ Document ] document The document to calculate on. + # @param [ Mongoid::Document ] document The document to calculate on. # # @return [ Mongoid::Atomic::Paths::Embedded::One ] # The embedded one atomic path calculator. diff --git a/lib/mongoid/association/many.rb b/lib/mongoid/association/many.rb index 67d492e5c..c2626243e 100644 --- a/lib/mongoid/association/many.rb +++ b/lib/mongoid/association/many.rb @@ -31,7 +31,7 @@ def blank? # @param [ Hash ] attributes The attributes to create with. # @param [ Class ] type The optional type of document to create. # - # @return [ Document ] The newly created document. + # @return [ Mongoid::Document ] The newly created document. def create(attributes = nil, type = nil, &block) if attributes.is_a?(::Array) attributes.map { |attrs| create(attrs, type, &block) } @@ -54,7 +54,7 @@ def create(attributes = nil, type = nil, &block) # # @raise [ Errors::Validations ] If validation failed. # - # @return [ Document ] The newly created document. + # @return [ Mongoid::Document ] The newly created document. def create!(attributes = nil, type = nil, &block) if attributes.is_a?(::Array) attributes.map { |attrs| create!(attrs, type, &block) } @@ -79,7 +79,7 @@ def create!(attributes = nil, type = nil, &block) # @param [ Hash ] attrs The attributes to search or create with. # @param [ Class ] type The optional type of document to create. # - # @return [ Document ] An existing document or newly created one. + # @return [ Mongoid::Document ] An existing document or newly created one. def find_or_create_by(attrs = {}, type = nil, &block) find_or(:create, attrs, type, &block) end @@ -95,7 +95,7 @@ def find_or_create_by(attrs = {}, type = nil, &block) # # @raise [ Errors::Validations ] If validation failed. # - # @return [ Document ] An existing document or newly created one. + # @return [ Mongoid::Document ] An existing document or newly created one. def find_or_create_by!(attrs = {}, type = nil, &block) find_or(:create!, attrs, type, &block) end @@ -109,7 +109,7 @@ def find_or_create_by!(attrs = {}, type = nil, &block) # @param [ Hash ] attrs The attributes to search or initialize with. # @param [ Class ] type The optional subclass to build. # - # @return [ Document ] An existing document or newly instantiated one. + # @return [ Mongoid::Document ] An existing document or newly instantiated one. def find_or_initialize_by(attrs = {}, type = nil, &block) find_or(:build, attrs, type, &block) end @@ -143,7 +143,7 @@ def respond_to?(name, include_private = false) # @example Get the scoped association. # relation.scoped # - # @return [ Criteria ] The scoped criteria. + # @return [ Mongoid::Criteria ] The scoped criteria. def scoped criteria end @@ -172,7 +172,7 @@ def serializable_hash(options = {}) # @example Get the unscoped criteria. # person.addresses.unscoped # - # @return [ Criteria ] The unscoped criteria. + # @return [ Mongoid::Criteria ] The unscoped criteria. def unscoped criteria.unscoped end @@ -192,7 +192,7 @@ def _session # @param [ Hash ] attrs The attributes to search or build with. # @param [ Class ] type The optional subclass to build. # - # @return [ Document ] A matching document or a new/created one. + # @return [ Mongoid::Document ] A matching document or a new/created one. def find_or(method, attrs = {}, type = nil, &block) attrs[klass.discriminator_key] = type.discriminator_value if type where(attrs).first || send(method, attrs, type, &block) diff --git a/lib/mongoid/association/nested/many.rb b/lib/mongoid/association/nested/many.rb index b84f51692..9941c3e8c 100644 --- a/lib/mongoid/association/nested/many.rb +++ b/lib/mongoid/association/nested/many.rb @@ -19,7 +19,7 @@ class Many # @example Build the nested attrs. # many.build(person) # - # @param [ Document ] parent The parent document of the association. + # @param [ Mongoid::Document ] parent The parent document of the association. # @param [ Hash ] options The options. # # @return [ Array ] The attributes. @@ -96,7 +96,7 @@ def over_limit?(attributes) # @example Process the attributes # builder.process_attributes({ "id" => 1, "street" => "Bond" }) # - # @param [ Document ] parent The parent document. + # @param [ Mongoid::Document ] parent The parent document. # @param [ Hash ] attrs The single document attributes to process. def process_attributes(parent, attrs) return if reject?(parent, attrs) @@ -115,9 +115,9 @@ def process_attributes(parent, attrs) # @example Destroy the child. # builder.destroy(parent, relation, doc) # - # @param [ Document ] parent The parent document. - # @param [ Proxy ] relation The association proxy. - # @param [ Document ] doc The doc to destroy. + # @param [ Mongoid::Document ] parent The parent document. + # @param [ Mongoid::Association::Proxy ] relation The association proxy. + # @param [ Mongoid::Document ] doc The doc to destroy. def destroy(parent, relation, doc) doc.flagged_for_destroy = true if !doc.embedded? || parent.new_record? @@ -134,8 +134,8 @@ def destroy(parent, relation, doc) # @example Destroy the document. # builder.destroy_document(relation, doc) # - # @param [ Proxy ] relation The association proxy. - # @param [ Document ] doc The document to delete. + # @param [ Mongoid::Association::Proxy ] relation The association proxy. + # @param [ Mongoid::Document ] doc The document to delete. def destroy_document(relation, doc) res = doc.destroy unless doc.embedded? || doc.destroyed? relation.delete(doc) @@ -149,7 +149,7 @@ def destroy_document(relation, doc) # @example Update the document. # builder.update_document(doc, {}, options) # - # @param [ Document ] doc The document to update. + # @param [ Mongoid::Document ] doc The document to update. # @param [ Hash ] attrs The attributes. def update_document(doc, attrs) attrs.delete_id @@ -167,7 +167,7 @@ def update_document(doc, attrs) # @example Update nested association. # builder.update_nested_relation(parent, id, attrs) # - # @param [ Document ] parent The parent document. + # @param [ Mongoid::Document ] parent The parent document. # @param [ String | BSON::ObjectId ] id of the related document. # @param [ Hash ] attrs The single document attributes to process. def update_nested_relation(parent, id, attrs) diff --git a/lib/mongoid/association/nested/nested_buildable.rb b/lib/mongoid/association/nested/nested_buildable.rb index f7953c0e2..cedcdc12a 100644 --- a/lib/mongoid/association/nested/nested_buildable.rb +++ b/lib/mongoid/association/nested/nested_buildable.rb @@ -26,7 +26,7 @@ def allow_destroy? # @example Is there a reject proc? # builder.reject? # - # @param [ Document ] document The parent document of the association + # @param [ Mongoid::Document ] document The parent document of the association # @param [ Hash ] attrs The attributes to check for rejection. # # @return [ true | false ] True and call proc or method if rejectable, false if not. diff --git a/lib/mongoid/association/nested/one.rb b/lib/mongoid/association/nested/one.rb index 02c1e22cc..79841a604 100644 --- a/lib/mongoid/association/nested/one.rb +++ b/lib/mongoid/association/nested/one.rb @@ -21,9 +21,9 @@ class One # the existing association, a replacement of the association with a new # document, or a removal of the association. # - # @param [ Document ] parent The parent document. + # @param [ Mongoid::Document ] parent The parent document. # - # @return [ Document ] The built document. + # @return [ Mongoid::Document ] The built document. def build(parent) return if reject?(parent, attributes) @existing = parent.send(association.name) diff --git a/lib/mongoid/association/one.rb b/lib/mongoid/association/one.rb index b43f45a01..5b7bf0669 100644 --- a/lib/mongoid/association/one.rb +++ b/lib/mongoid/association/one.rb @@ -22,7 +22,7 @@ def clear # @example Get the in memory documents. # relation.in_memory # - # @return [ Array ] The documents in memory. + # @return [ Array ] The documents in memory. def in_memory [ _target ] end diff --git a/lib/mongoid/association/options.rb b/lib/mongoid/association/options.rb index a88313c77..766903192 100644 --- a/lib/mongoid/association/options.rb +++ b/lib/mongoid/association/options.rb @@ -22,7 +22,7 @@ def dependent # The custom sorting options on the association. # - # @return [ Criteria::Queryable::Key ] The custom sorting options. + # @return [ Mongoid::Criteria::Queryable::Key ] The custom sorting options. def order @options[:order] end diff --git a/lib/mongoid/association/proxy.rb b/lib/mongoid/association/proxy.rb index bcc066213..31bb50b46 100644 --- a/lib/mongoid/association/proxy.rb +++ b/lib/mongoid/association/proxy.rb @@ -47,8 +47,8 @@ class Proxy # @example Initialize the proxy. # proxy.init(person, name, association) # - # @param [ Document ] base The base document on the proxy. - # @param [ Document | Array ] target The target of the proxy. + # @param [ Mongoid::Document ] base The base document on the proxy. + # @param [ Mongoid::Document | Array ] target The target of the proxy. # @param [ Mongoid::Association::Relatable ] association The association metadata. def init(base, target, association) @_base, @_target, @_association = base, target, association @@ -109,7 +109,7 @@ def collection # @example Set the association metadata. # proxt.characterize_one(name) # - # @param [ Document ] document The document to set on. + # @param [ Mongoid::Document ] document The document to set on. def characterize_one(document) document._association = _association unless document._association end @@ -151,7 +151,7 @@ def raise_mixed # @example Raise the error. # relation.raise_unsaved(post) # - # @param [ Document ] doc The child document getting created. + # @param [ Mongoid::Document ] doc The child document getting created. # # @raise [ Errors::UnsavedDocument ] The error. def raise_unsaved(doc) @@ -193,10 +193,10 @@ class << self # @example Apply the ordering. # Proxy.apply_ordering(criteria, association) # - # @param [ Criteria ] criteria The criteria to modify. + # @param [ Mongoid::Criteria ] criteria The criteria to modify. # @param [ Mongoid::Association::Relatable ] association The association metadata. # - # @return [ Criteria ] The ordered criteria. + # @return [ Mongoid::Criteria ] The ordered criteria. def apply_ordering(criteria, association) association.order ? criteria.order_by(association.order) : criteria end diff --git a/lib/mongoid/association/referenced/belongs_to.rb b/lib/mongoid/association/referenced/belongs_to.rb index a40af16c5..068061b8d 100644 --- a/lib/mongoid/association/referenced/belongs_to.rb +++ b/lib/mongoid/association/referenced/belongs_to.rb @@ -124,7 +124,7 @@ def nested_builder(attributes, options) # @example Get the path calculator. # association.path(document) # - # @param [ Document ] document The document to calculate on. + # @param [ Mongoid::Document ] document The document to calculate on. # # @return [ Root ] The root atomic path calculator. def path(document) diff --git a/lib/mongoid/association/referenced/belongs_to/binding.rb b/lib/mongoid/association/referenced/belongs_to/binding.rb index 2ac07ab4d..ffbd3e500 100644 --- a/lib/mongoid/association/referenced/belongs_to/binding.rb +++ b/lib/mongoid/association/referenced/belongs_to/binding.rb @@ -67,7 +67,7 @@ def unbind_one # @example Check for inverses errors. # binding.check_inverses!(doc) # - # @param [ Document ] doc The document to check. + # @param [ Mongoid::Document ] doc The document to check. def check_polymorphic_inverses!(doc) inverses = _association.inverses(doc) if inverses.length > 1 && _base.send(_association.foreign_key).nil? diff --git a/lib/mongoid/association/referenced/belongs_to/buildable.rb b/lib/mongoid/association/referenced/belongs_to/buildable.rb index e59b40d1f..6186db6bf 100644 --- a/lib/mongoid/association/referenced/belongs_to/buildable.rb +++ b/lib/mongoid/association/referenced/belongs_to/buildable.rb @@ -19,7 +19,7 @@ module Buildable # @param [ String ] type The type of the association. # @param [ nil ] selected_fields Must be nil. # - # @return [ Document ] A single document. + # @return [ Mongoid::Document ] A single document. def build(base, object, type = nil, selected_fields = nil) return object unless query?(object) execute_query(object, type) diff --git a/lib/mongoid/association/referenced/belongs_to/proxy.rb b/lib/mongoid/association/referenced/belongs_to/proxy.rb index f0e2f445f..f9fe258d3 100644 --- a/lib/mongoid/association/referenced/belongs_to/proxy.rb +++ b/lib/mongoid/association/referenced/belongs_to/proxy.rb @@ -20,8 +20,8 @@ class Proxy < Association::One # @example Create the new proxy. # Association::BelongsTo::Proxy.new(game, person, association) # - # @param [ Document ] base The document this association hangs off of. - # @param [ Document | Array ] target The target (parent) of the + # @param [ Mongoid::Document ] base The document this association hangs off of. + # @param [ Mongoid::Document | Array ] target The target (parent) of the # association. # @param [ Mongoid::Association::Relatable ] association The association object. def initialize(base, target, association) @@ -48,7 +48,7 @@ def nullify # @example Substitute the association. # name.substitute(new_name) # - # @param [ Document | Array ] replacement The replacement. + # @param [ Mongoid::Document | Array ] replacement The replacement. # # @return [ self | nil ] The association or nil. def substitute(replacement) @@ -79,9 +79,9 @@ def binding # @example Normalize the substitute. # proxy.normalize(id) # - # @param [ Document | Object ] replacement The replacement object. + # @param [ Mongoid::Document | Object ] replacement The replacement object. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def normalize(replacement) return replacement if replacement.is_a?(Document) _association.build(klass, replacement) @@ -104,7 +104,7 @@ class << self # @example Get the eager loader object # # @param [ Mongoid::Association::Relatable ] association The association object. - # @param [ Array ] docs The array of documents. + # @param [ Array ] docs The array of documents. # # @return [ Mongoid::Association::Referenced::BelongsTo::Eager ] # The eager loader. diff --git a/lib/mongoid/association/referenced/has_and_belongs_to_many.rb b/lib/mongoid/association/referenced/has_and_belongs_to_many.rb index 986f13489..e87e66f56 100644 --- a/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +++ b/lib/mongoid/association/referenced/has_and_belongs_to_many.rb @@ -129,7 +129,7 @@ def inverse_foreign_key # Whether trying to bind an object using this association should raise # an error. # - # @param [ Document ] doc The document to be bound. + # @param [ Mongoid::Document ] doc The document to be bound. # # @return [ true | false ] Whether the document can be bound. def bindable?(doc) @@ -159,7 +159,7 @@ def nested_builder(attributes, options) # @example Get the path calculator. # association.path(document) # - # @param [ Document ] document The document to calculate on. + # @param [ Mongoid::Document ] document The document to calculate on. # # @return [ Root ] The root atomic path calculator. def path(document) diff --git a/lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb b/lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb index a7bba337f..fb897ac73 100644 --- a/lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb +++ b/lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb @@ -15,7 +15,7 @@ class Binding # @example Bind one document. # person.preferences.bind_one(preference) # - # @param [ Document ] doc The single document to bind. + # @param [ Mongoid::Document ] doc The single document to bind. def bind_one(doc) binding do inverse_keys = doc.you_must(_association.inverse_foreign_key) diff --git a/lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb b/lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb index e333403bb..487a15d90 100644 --- a/lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb +++ b/lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb @@ -19,7 +19,7 @@ module Buildable # @param [ String ] type Not used in this context. # @param [ nil ] selected_fields Must be nil. # - # @return [ Array ] The documents. + # @return [ Array ] The documents. def build(base, object, type = nil, selected_fields = nil) if query?(object) query_criteria(object) diff --git a/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb b/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb index 0b674c760..cf69f0922 100644 --- a/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +++ b/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb @@ -26,9 +26,9 @@ class Proxy < Referenced::HasMany::Proxy # @example Concat with other documents. # person.posts.concat([ post_one, post_two ]) # - # @param [ Document... ] *args Any number of documents. + # @param [ Mongoid::Document... ] *args Any number of documents. # - # @return [ Array ] The loaded docs. + # @return [ Array ] The loaded docs. def <<(*args) docs = args.flatten return concat(docs) if docs.size > 1 @@ -74,9 +74,9 @@ def <<(*args) # @example Concat with other documents. # person.posts.concat([ post_one, post_two ]) # - # @param [ Array ] documents The docs to add. + # @param [ Array ] documents The docs to add. # - # @return [ Array ] The documents. + # @return [ Array ] The documents. def concat(documents) ids, docs, inserts = {}, [], [] documents.each do |doc| @@ -108,7 +108,7 @@ def concat(documents) # @param [ Hash ] attributes The attributes of the new document. # @param [ Class ] type The optional subclass to build. # - # @return [ Document ] The new document. + # @return [ Mongoid::Document ] The new document. def build(attributes = {}, type = nil) doc = Factory.execute_build(type || klass, attributes, execute_callbacks: false) append(doc) @@ -129,9 +129,9 @@ def build(attributes = {}, type = nil) # @example Delete the document. # person.posts.delete(post) # - # @param [ Document ] document The document to remove. + # @param [ Mongoid::Document ] document The document to remove. # - # @return [ Document ] The matching document. + # @return [ Mongoid::Document ] The matching document. def delete(document) doc = super if doc && persistable? @@ -149,7 +149,7 @@ def delete(document) # @example Nullify the association. # person.preferences.nullify # - # @param [ Array ] replacement The replacement documents. + # @param [ Array ] replacement The replacement documents. def nullify(replacement = []) _target.each do |doc| execute_callback :before_remove, doc @@ -199,7 +199,7 @@ def nullify(replacement = []) # @example Replace the association. # person.preferences.substitute([ new_post ]) # - # @param [ Array ] replacement The replacement target. + # @param [ Array ] replacement The replacement target. # # @return [ Many ] The association. def substitute(replacement) @@ -219,7 +219,7 @@ def substitute(replacement) # @example Get the unscoped criteria. # person.preferences.unscoped # - # @return [ Criteria ] The unscoped criteria. + # @return [ Mongoid::Criteria ] The unscoped criteria. def unscoped klass.unscoped.any_in(_id: _base.public_send(foreign_key)) end @@ -258,7 +258,7 @@ def reset_foreign_key_changes # @example Append the document to the association. # relation.append(document) # - # @param [ Document ] document The document to append to the target. + # @param [ Mongoid::Document ] document The document to append to the target. def append(document) execute_callbacks_around(:add, document) do _target.push(document) @@ -285,7 +285,7 @@ def binding # @example Is the child persistable? # relation.child_persistable?(doc) # - # @param [ Document ] doc The document. + # @param [ Mongoid::Document ] doc The document. # # @return [ true | false ] If the document can be persisted. def child_persistable?(doc) @@ -299,7 +299,7 @@ def child_persistable?(doc) # @example Get a criteria for the association. # relation.criteria # - # @return [ Criteria ] A new criteria. + # @return [ Mongoid::Criteria ] A new criteria. def criteria(id_list = nil) _association.criteria(_base, id_list) end @@ -311,7 +311,7 @@ def criteria(id_list = nil) # @example Flag as unsynced. # relation.unsynced(doc, :preference_ids) # - # @param [ Document ] doc The document to flag. + # @param [ Mongoid::Document ] doc The document to flag. # @param [ Symbol ] key The key to flag on the document. # # @return [ true ] true. @@ -327,7 +327,7 @@ class << self # @example Get the eager loader object # # @param [ Mongoid::Association::Relatable ] association The association metadata. - # @param [ Array ] docs The array of documents. + # @param [ Array ] docs The array of documents. # # @return [ Mongoid::Association::Referenced::HasAndBelongsToMany::Eager ] # The eager loader. diff --git a/lib/mongoid/association/referenced/has_many.rb b/lib/mongoid/association/referenced/has_many.rb index dcccb465b..a3536d46d 100644 --- a/lib/mongoid/association/referenced/has_many.rb +++ b/lib/mongoid/association/referenced/has_many.rb @@ -148,7 +148,7 @@ def polymorphic? # Whether trying to bind an object using this association should raise # an error. # - # @param [ Document ] doc The document to be bound. + # @param [ Mongoid::Document ] doc The document to be bound. # # @return [ true | false ] Whether the document can be bound. def bindable?(doc) @@ -170,7 +170,7 @@ def nested_builder(attributes, options) # @example Get the path calculator. # Proxy.path(document) # - # @param [ Document ] document The document to calculate on. + # @param [ Mongoid::Document ] document The document to calculate on. # # @return [ Root ] The root atomic path calculator. def path(document) diff --git a/lib/mongoid/association/referenced/has_many/buildable.rb b/lib/mongoid/association/referenced/has_many/buildable.rb index 23419d05b..1fcbb8810 100644 --- a/lib/mongoid/association/referenced/has_many/buildable.rb +++ b/lib/mongoid/association/referenced/has_many/buildable.rb @@ -19,7 +19,7 @@ module Buildable # @param [ String ] type The type of document to query for. # @param [ nil ] selected_fields Must be nil. # - # @return [ Document ] A single document. + # @return [ Mongoid::Document ] A single document. def build(base, object, type = nil, selected_fields = nil) return (object || []) unless query?(object) return [] if object.is_a?(Array) diff --git a/lib/mongoid/association/referenced/has_many/enumerable.rb b/lib/mongoid/association/referenced/has_many/enumerable.rb index 139e09fc8..6107cce95 100644 --- a/lib/mongoid/association/referenced/has_many/enumerable.rb +++ b/lib/mongoid/association/referenced/has_many/enumerable.rb @@ -53,9 +53,9 @@ def ===(other) # @example Append the document. # enumerable << document # - # @param [ Document ] document The document to append. + # @param [ Mongoid::Document ] document The document to append. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def <<(document) _added[document._id] = document self @@ -74,7 +74,7 @@ def <<(document) # doc.unbind # end # - # @return [ Array ] The cleared out _added docs. + # @return [ Array ] The cleared out _added docs. def clear if block_given? in_memory { |doc| yield(doc) } @@ -89,7 +89,7 @@ def clear # @example Clone the enumerable. # enumerable.clone # - # @return [ Array ] An array clone of the enumerable. + # @return [ Array ] An array clone of the enumerable. def clone collect { |doc| doc.clone } end @@ -99,9 +99,9 @@ def clone # @example Delete the document. # enumerable.delete(document) # - # @param [ Document ] document The document to delete. + # @param [ Mongoid::Document ] document The document to delete. # - # @return [ Document ] The deleted document. + # @return [ Mongoid::Document ] The deleted document. def delete(document) doc = (_loaded.delete(document._id) || _added.delete(document._id)) unless doc @@ -124,7 +124,7 @@ def delete(document) # dod._id == _id # end # - # @return [ Array ] The remaining docs. + # @return [ Array ] The remaining docs. def delete_if(&block) load_all! deleted = in_memory.select(&block) @@ -241,7 +241,7 @@ def any?(*args) # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The first document found. + # @return [ Mongoid::Document ] The first document found. def first(limit = nil) _loaded.try(:values).try(:first) || _added[(ul = _unloaded.try(:first, limit)).try(:_id)] || @@ -257,7 +257,7 @@ def first(limit = nil) # @example Initialize the enumerable with an array. # Enumerable.new([ post ]) # - # @param [ Criteria | Array ] target The wrapped object. + # @param [ Mongoid::Criteria | Array ] target The wrapped object. def initialize(target, base = nil, association = nil) @_base = base @_association = association @@ -277,7 +277,7 @@ def initialize(target, base = nil, association = nil) # @example Does the target include the document? # enumerable.include?(document) # - # @param [ Document ] doc The document to check. + # @param [ Mongoid::Document ] doc The document to check. # # @return [ true | false ] If the document is in the target. def include?(doc) @@ -304,7 +304,7 @@ def inspect # @example Get the in memory docs. # enumerable.in_memory # - # @return [ Array ] The in memory docs. + # @return [ Array ] The in memory docs. def in_memory docs = (_loaded.values + _added.values) docs.each do |doc| @@ -326,7 +326,7 @@ def in_memory # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The last document found. + # @return [ Mongoid::Document ] The last document found. def last(limit = nil) _added.values.try(:last) || _loaded.try(:values).try(:last) || @@ -391,7 +391,7 @@ def reset # @example Reset the unloaded documents. # enumerable.reset_unloaded(criteria) # - # @param [ Criteria ] criteria The criteria to replace with. + # @param [ Mongoid::Criteria ] criteria The criteria to replace with. def reset_unloaded(criteria) @_unloaded = criteria if _unloaded.is_a?(Criteria) end @@ -459,7 +459,7 @@ def as_json(options = {}) # @example Get all the unique documents. # enumerable.uniq # - # @return [ Array ] The unique documents. + # @return [ Array ] The unique documents. def uniq entries.uniq end diff --git a/lib/mongoid/association/referenced/has_many/proxy.rb b/lib/mongoid/association/referenced/has_many/proxy.rb index 6c6278214..1ed7d88d3 100644 --- a/lib/mongoid/association/referenced/has_many/proxy.rb +++ b/lib/mongoid/association/referenced/has_many/proxy.rb @@ -29,9 +29,9 @@ class Proxy < Association::Many # @example Concat with other documents. # person.posts.concat([ post_one, post_two ]) # - # @param [ Document... ] *args Any number of documents. + # @param [ Mongoid::Document... ] *args Any number of documents. # - # @return [ Array ] The loaded docs. + # @return [ Array ] The loaded docs. def <<(*args) docs = args.flatten return concat(docs) if docs.size > 1 @@ -50,9 +50,9 @@ def <<(*args) # @example Concat with other documents. # person.posts.concat([ post_one, post_two ]) # - # @param [ Array ] documents The docs to add. + # @param [ Array ] documents The docs to add. # - # @return [ Array ] The documents. + # @return [ Array ] The documents. def concat(documents) docs, inserts = [], [] documents.each do |doc| @@ -73,7 +73,7 @@ def concat(documents) # @param [ Hash ] attributes The attributes of the new document. # @param [ Class ] type The optional subclass to build. # - # @return [ Document ] The new document. + # @return [ Mongoid::Document ] The new document. def build(attributes = {}, type = nil) doc = Factory.execute_build(type || klass, attributes, execute_callbacks: false) append(doc) @@ -93,9 +93,9 @@ def build(attributes = {}, type = nil) # @example Delete the document. # person.posts.delete(post) # - # @param [ Document ] document The document to remove. + # @param [ Mongoid::Document ] document The document to remove. # - # @return [ Document ] The matching document. + # @return [ Mongoid::Document ] The matching document. def delete(document) execute_callbacks_around(:remove, document) do _target.delete(document) do |doc| @@ -151,7 +151,7 @@ def destroy_all(conditions = nil) # post.save # end # - # @return [ Array ] The loaded docs. + # @return [ Array ] The loaded docs. def each if block_given? _target.each { |doc| yield(doc) } @@ -207,7 +207,7 @@ def exists? # @param &block Optional block to pass. # @yield [ Object ] Yields each enumerable element to the block. # - # @return [ Document | Array | nil ] A document or matching documents. + # @return [ Mongoid::Document | Array | nil ] A document or matching documents. def find(*args, &block) matching = criteria.find(*args, &block) Array(matching).each { |doc| _target.push(doc) } @@ -220,8 +220,8 @@ def find(*args, &block) # @example Create the new association. # Referenced::Many.new(base, target, association) # - # @param [ Document ] base The document this association hangs off of. - # @param [ Array ] target The target of the association. + # @param [ Mongoid::Document ] base The document this association hangs off of. + # @param [ Array ] target The target of the association. # @param [ Mongoid::Association::Relatable ] association The association metadata. def initialize(base, target, association) enum = HasMany::Enumerable.new(target, base, association) @@ -283,7 +283,7 @@ def purge # @example Replace the association. # person.posts.substitute([ new_post ]) # - # @param [ Array ] replacement The replacement target. + # @param [ Array ] replacement The replacement target. # # @return [ Many ] The association. def substitute(replacement) @@ -307,7 +307,7 @@ def substitute(replacement) # @example Get the unscoped criteria. # person.posts.unscoped # - # @return [ Criteria ] The unscoped criteria. + # @return [ Mongoid::Criteria ] The unscoped criteria. def unscoped klass.unscoped.where(foreign_key => _base.send(_association.primary_key)) end @@ -320,7 +320,7 @@ def unscoped # @example Append the document to the association. # relation.append(document) # - # @param [ Document ] document The document to append to the target. + # @param [ Mongoid::Document ] document The document to append to the target. def append(document) with_add_callbacks(document, already_related?(document)) do _target.push(document) @@ -335,7 +335,7 @@ def append(document) # @example Execute before/after add callbacks around the block. # relation.with_add_callbacks(document, false) # - # @param [ Document ] document The document to append to the target. + # @param [ Mongoid::Document ] document The document to append to the target. # @param [ true | false ] already_related Whether the document is already related # to the target. def with_add_callbacks(document, already_related) @@ -349,7 +349,7 @@ def with_add_callbacks(document, already_related) # @example Is the document already related to the base. # relation.already_related?(document) # - # @param [ Document ] document The document to possibly append to the target. + # @param [ Mongoid::Document ] document The document to possibly append to the target. # # @return [ true | false ] Whether the document is already related to the base and the # association is persisted. @@ -386,7 +386,7 @@ def collection # @example Get a criteria for the association. # relation.criteria # - # @return [ Criteria ] A new criteria. + # @return [ Mongoid::Criteria ] A new criteria. def criteria @criteria ||= _association.criteria(_base) end @@ -397,7 +397,7 @@ def criteria # @example Cascade the change. # relation.cascade!(document) # - # @param [ Document ] document The document to cascade on. + # @param [ Mongoid::Document ] document The document to cascade on. # # @return [ true | false ] If the association is destructive. def cascade!(document) @@ -422,7 +422,7 @@ def cascade!(document) # @param [ Object... ] *args The method args # @param &block Optional block to pass. # - # @return [ Criteria | Object ] A Criteria or return value from the target. + # @return [ Mongoid::Criteria | Object ] A Criteria or return value from the target. ruby2_keywords def method_missing(name, *args, &block) if _target.respond_to?(name) _target.send(name, *args, &block) @@ -440,7 +440,7 @@ def cascade!(document) # @example Persist the delayed batch inserts. # relation.persist_delayed([ doc ]) # - # @param [ Array ] docs The delayed inserts. + # @param [ Array ] docs The delayed inserts. # @param [ Array ] inserts The raw insert document. def persist_delayed(docs, inserts) unless docs.empty? @@ -520,8 +520,8 @@ def remove_not_in(ids) # @example Save or delay the document. # relation.save_or_delay(doc, []) # - # @param [ Document ] doc The document. - # @param [ Array ] inserts The inserts. + # @param [ Mongoid::Document ] doc The document. + # @param [ Array ] inserts The inserts. def save_or_delay(doc, docs, inserts) if doc.new_record? && doc.valid?(:create) doc.run_before_callbacks(:save, :create) diff --git a/lib/mongoid/association/referenced/has_one.rb b/lib/mongoid/association/referenced/has_one.rb index 760402057..cada26888 100644 --- a/lib/mongoid/association/referenced/has_one.rb +++ b/lib/mongoid/association/referenced/has_one.rb @@ -109,7 +109,7 @@ def type # Whether trying to bind an object using this association should raise # an error. # - # @param [ Document ] doc The document to be bound. + # @param [ Mongoid::Document ] doc The document to be bound. # # @return [ true | false ] Whether the document can be bound. def bindable?(doc) @@ -126,7 +126,7 @@ def stores_foreign_key?; false; end # @example Get the path calculator. # Proxy.path(document) # - # @param [ Document ] document The document to calculate on. + # @param [ Mongoid::Document ] document The document to calculate on. # # @return [ Root ] The root atomic path calculator. def path(document) diff --git a/lib/mongoid/association/referenced/has_one/buildable.rb b/lib/mongoid/association/referenced/has_one/buildable.rb index f23e3b2f3..ee45f6486 100644 --- a/lib/mongoid/association/referenced/has_one/buildable.rb +++ b/lib/mongoid/association/referenced/has_one/buildable.rb @@ -17,7 +17,7 @@ module Buildable # @param [ String ] type The type of the association. # @param [ nil ] selected_fields Must be nil. # - # @return [ Document ] A single document. + # @return [ Mongoid::Document ] A single document. def build(base, object, type = nil, selected_fields = nil) if query?(object) if !base.new_record? diff --git a/lib/mongoid/association/referenced/has_one/proxy.rb b/lib/mongoid/association/referenced/has_one/proxy.rb index 356b51936..2801f27c8 100644 --- a/lib/mongoid/association/referenced/has_one/proxy.rb +++ b/lib/mongoid/association/referenced/has_one/proxy.rb @@ -19,8 +19,8 @@ class Proxy < Association::One # @example Create the new association. # Referenced::One.new(base, target, association) # - # @param [ Document ] base The document this association hangs off of. - # @param [ Document ] target The target (child) of the association. + # @param [ Mongoid::Document ] base The document this association hangs off of. + # @param [ Mongoid::Document ] target The target (child) of the association. # @param [ Mongoid::Association::Relatable ] association The association metadata. def initialize(base, target, association) init(base, target, association) do @@ -49,7 +49,7 @@ def nullify # @example Replace the association. # person.game.substitute(new_game) # - # @param [ Array ] replacement The replacement target. + # @param [ Array ] replacement The replacement target. # # @return [ One ] The association. def substitute(replacement) diff --git a/lib/mongoid/association/relatable.rb b/lib/mongoid/association/relatable.rb index bcc56be8b..9fc0ede1f 100644 --- a/lib/mongoid/association/relatable.rb +++ b/lib/mongoid/association/relatable.rb @@ -86,7 +86,7 @@ def type_setter # Whether trying to bind an object using this association should raise # an error. # - # @param [ Document ] doc The document to be bound. + # @param [ Mongoid::Document ] doc The document to be bound. # # @return [ true | false ] Whether the document can be bound. def bindable?(doc); false; end @@ -247,11 +247,11 @@ def foreign_key_check # Create an association proxy object using the owner and target. # - # @param [ Document ] owner The document this association hangs off of. - # @param [ Document | Array ] target The target (parent) of the + # @param [ Mongoid::Document ] owner The document this association hangs off of. + # @param [ Mongoid::Document | Array ] target The target (parent) of the # association. # - # @return [ Proxy ] + # @return [ Mongoid::Association::Proxy ] def create_relation(owner, target) relation.new(owner, target, self) end diff --git a/lib/mongoid/atomic.rb b/lib/mongoid/atomic.rb index 7eb55d9d7..470cb4669 100644 --- a/lib/mongoid/atomic.rb +++ b/lib/mongoid/atomic.rb @@ -32,7 +32,7 @@ module Atomic # @example Add the atomic pull. # person.add_atomic_pull(address) # - # @param [ Document ] document The embedded document to pull. + # @param [ Mongoid::Document ] document The embedded document to pull. def add_atomic_pull(document) document.flagged_for_destroy = true key = document.association_name.to_s @@ -45,9 +45,9 @@ def add_atomic_pull(document) # @example Add an atomic unset. # document.add_atomic_unset(doc) # - # @param [ Document ] document The child document. + # @param [ Mongoid::Document ] document The child document. # - # @return [ Array ] The children. + # @return [ Array ] The children. def add_atomic_unset(document) document.flagged_for_destroy = true key = document.association_name.to_s @@ -317,7 +317,7 @@ def process_flagged_destroys # model.generate_atomic_updates(mods, doc) # # @param [ Modifiers ] mods The atomic modifications. - # @param [ Document ] doc The document to update for. + # @param [ Mongoid::Document ] doc The document to update for. def generate_atomic_updates(mods, doc) mods.unset(doc.atomic_unsets) mods.pull(doc.atomic_pulls) diff --git a/lib/mongoid/atomic/paths/embedded/many.rb b/lib/mongoid/atomic/paths/embedded/many.rb index 293053381..c516cdf1d 100644 --- a/lib/mongoid/atomic/paths/embedded/many.rb +++ b/lib/mongoid/atomic/paths/embedded/many.rb @@ -15,7 +15,7 @@ class Many # @example Create the path util. # Many.new(document) # - # @param [ Document ] document The document to generate the paths for. + # @param [ Mongoid::Document ] document The document to generate the paths for. def initialize(document) @document, @parent = document, document._parent @insert_modifier, @delete_modifier ="$push", "$pull" @@ -44,7 +44,7 @@ class << self # require passing in a document to store, which we don't have when # trying to store the empty list. # - # @param [ Document ] parent The parent document to store in. + # @param [ Mongoid::Document ] parent The parent document to store in. # @param [ Mongoid::Association::Relatable ] association The association metadata. # # @return [ String ] The position string. diff --git a/lib/mongoid/atomic/paths/embedded/one.rb b/lib/mongoid/atomic/paths/embedded/one.rb index 90e0f6640..caec6c875 100644 --- a/lib/mongoid/atomic/paths/embedded/one.rb +++ b/lib/mongoid/atomic/paths/embedded/one.rb @@ -15,7 +15,7 @@ class One # @example Create the path util. # One.new(document) # - # @param [ Document ] document The document to generate the paths for. + # @param [ Mongoid::Document ] document The document to generate the paths for. def initialize(document) @document, @parent = document, document._parent @insert_modifier, @delete_modifier ="$set", "$unset" diff --git a/lib/mongoid/atomic/paths/root.rb b/lib/mongoid/atomic/paths/root.rb index 21b8cc55e..a2fea9879 100644 --- a/lib/mongoid/atomic/paths/root.rb +++ b/lib/mongoid/atomic/paths/root.rb @@ -15,7 +15,7 @@ class Root # @example Create the root path util. # Root.new(document) # - # @param [ Document ] document The document to generate the paths for. + # @param [ Mongoid::Document ] document The document to generate the paths for. def initialize(document) @document, @path, @position = document, "", "" end diff --git a/lib/mongoid/contextual.rb b/lib/mongoid/contextual.rb index 7a0bc2386..dbd2b3117 100644 --- a/lib/mongoid/contextual.rb +++ b/lib/mongoid/contextual.rb @@ -44,7 +44,7 @@ def context # Note that depending on the context and on the Mongoid configuration, # documents can be loaded synchronously on the caller's thread. # - # @return [ Criteria ] Returns self. + # @return [ Mongoid::Criteria ] Returns self. def load_async context.load_async if context.respond_to?(:load_async) self diff --git a/lib/mongoid/contextual/aggregable/memory.rb b/lib/mongoid/contextual/aggregable/memory.rb index 451e84222..b8d2d34be 100644 --- a/lib/mongoid/contextual/aggregable/memory.rb +++ b/lib/mongoid/contextual/aggregable/memory.rb @@ -50,7 +50,7 @@ def avg(field) # # @param [ Symbol ] field The field to max. # - # @return [ Numeric | Document ] The max value or document with the max + # @return [ Numeric | Mongoid::Document ] The max value or document with the max # value. def max(field = nil) return super() if block_given? @@ -72,7 +72,7 @@ def max(field = nil) # # @param [ Symbol ] field The field to min. # - # @return [ Numeric | Document ] The min value or document with the min + # @return [ Numeric | Mongoid::Document ] The min value or document with the min # value. def min(field = nil) return super() if block_given? diff --git a/lib/mongoid/contextual/aggregable/mongo.rb b/lib/mongoid/contextual/aggregable/mongo.rb index 1ebba5702..7dd172ebf 100644 --- a/lib/mongoid/contextual/aggregable/mongo.rb +++ b/lib/mongoid/contextual/aggregable/mongo.rb @@ -60,7 +60,7 @@ def avg(field) # # @param [ Symbol ] field The field to max. # - # @return [ Float | Document ] The max value or document with the max + # @return [ Numeric | Mongoid::Document ] The max value or document with the max # value. def max(field = nil) block_given? ? super() : aggregates(field)["max"] @@ -80,7 +80,7 @@ def max(field = nil) # # @param [ Symbol ] field The field to min. # - # @return [ Float | Document ] The min value or document with the min + # @return [ Numeric | Mongoid::Document ] The min value or document with the min # value. def min(field = nil) block_given? ? super() : aggregates(field)["min"] diff --git a/lib/mongoid/contextual/geo_near.rb b/lib/mongoid/contextual/geo_near.rb index b1e6da37f..b6777bbe6 100644 --- a/lib/mongoid/contextual/geo_near.rb +++ b/lib/mongoid/contextual/geo_near.rb @@ -63,7 +63,7 @@ def distance_multiplier(value) # # @param [ Mongo::Collection ] collection The collection to run the # operation on. - # @param [ Criteria ] criteria The Mongoid criteria. + # @param [ Mongoid::Criteria ] criteria The Mongoid criteria. # @param [ String ] near def initialize(collection, criteria, near) @collection, @criteria = collection, criteria diff --git a/lib/mongoid/contextual/map_reduce.rb b/lib/mongoid/contextual/map_reduce.rb index 6e8abe29f..08785b963 100644 --- a/lib/mongoid/contextual/map_reduce.rb +++ b/lib/mongoid/contextual/map_reduce.rb @@ -70,7 +70,7 @@ def finalize(function) # @example Initialize the new map/reduce. # MapReduce.new(criteria, map, reduce) # - # @param [ Criteria ] criteria The Mongoid criteria. + # @param [ Mongoid::Criteria ] criteria The Mongoid criteria. # @param [ String ] map The map js function. # @param [ String ] reduce The reduce js function. def initialize(collection, criteria, map, reduce) diff --git a/lib/mongoid/contextual/memory.rb b/lib/mongoid/contextual/memory.rb index a02b3d21a..652c43915 100644 --- a/lib/mongoid/contextual/memory.rb +++ b/lib/mongoid/contextual/memory.rb @@ -138,7 +138,7 @@ def exists?(id_or_conditions = :none) # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The first document. + # @return [ Mongoid::Document ] The first document. def first(limit = nil) if limit eager_load(documents.first(limit)) @@ -155,7 +155,7 @@ def first(limit = nil) # @example Get the first document. # context.first! # - # @return [ Document ] The first document. + # @return [ Mongoid::Document ] The first document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -168,7 +168,7 @@ def first! # @example Create the new context. # Memory.new(criteria) # - # @param [ Criteria ] criteria The criteria. + # @param [ Mongoid::Criteria ] criteria The criteria. def initialize(criteria) @criteria, @klass = criteria, criteria.klass @documents = criteria.documents.select do |doc| @@ -201,7 +201,7 @@ def inc(incs) # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The last document. + # @return [ Mongoid::Document ] The last document. def last(limit = nil) if limit eager_load(documents.last(limit)) @@ -216,7 +216,7 @@ def last(limit = nil) # @example Get the last document. # context.last! # - # @return [ Document ] The last document. + # @return [ Mongoid::Document ] The last document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -299,7 +299,7 @@ def tally(field) # # @param [ Integer | nil ] limit The number of documents to take or nil. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def take(limit = nil) if limit eager_load(documents.take(limit)) @@ -314,7 +314,7 @@ def take(limit = nil) # @example Take a document. # context.take # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -379,7 +379,7 @@ def update_all(attributes = nil) # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The second document. + # @return [ Mongoid::Document ] The second document. def second eager_load([documents.second]).first end @@ -390,7 +390,7 @@ def second # @example Get the second document. # context.second! # - # @return [ Document ] The second document. + # @return [ Mongoid::Document ] The second document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -405,7 +405,7 @@ def second! # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The third document. + # @return [ Mongoid::Document ] The third document. def third eager_load([documents.third]).first end @@ -416,7 +416,7 @@ def third # @example Get the third document. # context.third! # - # @return [ Document ] The third document. + # @return [ Mongoid::Document ] The third document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -431,7 +431,7 @@ def third! # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The fourth document. + # @return [ Mongoid::Document ] The fourth document. def fourth eager_load([documents.fourth]).first end @@ -442,7 +442,7 @@ def fourth # @example Get the fourth document. # context.fourth! # - # @return [ Document ] The fourth document. + # @return [ Mongoid::Document ] The fourth document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -457,7 +457,7 @@ def fourth! # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The fifth document. + # @return [ Mongoid::Document ] The fifth document. def fifth eager_load([documents.fifth]).first end @@ -468,7 +468,7 @@ def fifth # @example Get the fifth document. # context.fifth! # - # @return [ Document ] The fifth document. + # @return [ Mongoid::Document ] The fifth document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -483,7 +483,7 @@ def fifth! # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The second to last document. + # @return [ Mongoid::Document ] The second to last document. def second_to_last eager_load([documents.second_to_last]).first end @@ -494,7 +494,7 @@ def second_to_last # @example Get the second to last document. # context.second_to_last! # - # @return [ Document ] The second to last document. + # @return [ Mongoid::Document ] The second to last document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -509,7 +509,7 @@ def second_to_last! # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The third to last document. + # @return [ Mongoid::Document ] The third to last document. def third_to_last eager_load([documents.third_to_last]).first end @@ -520,7 +520,7 @@ def third_to_last # @example Get the third to last document. # context.third_to_last! # - # @return [ Document ] The third to last document. + # @return [ Mongoid::Document ] The third to last document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -537,7 +537,7 @@ def third_to_last! # @example Get the documents for iteration. # context.documents_for_iteration # - # @return [ Array ] The docs to iterate. + # @return [ Array ] The docs to iterate. def documents_for_iteration docs = documents[skipping || 0, limiting || documents.length] || [] if eager_loadable? @@ -554,7 +554,7 @@ def documents_for_iteration # context.update_documents({}, doc) # # @param [ Hash ] attributes The attributes. - # @param [ Array ] docs The docs to update. + # @param [ Array ] docs The docs to update. def update_documents(attributes, docs) return false if !attributes || docs.empty? updates = { "$set" => {}} @@ -679,7 +679,7 @@ def in_place_sort(values) # @example Prepare for removal. # context.prepare_remove(doc) # - # @param [ Document ] doc The document. + # @param [ Mongoid::Document ] doc The document. def prepare_remove(doc) @selector ||= root.atomic_selector @path ||= doc.atomic_path @@ -753,7 +753,7 @@ def retrieve_value_at_path(document, field_path) # Pluck the field values from the given document. # - # @param [ Document ] doc The document to pluck from. + # @param [ Mongoid::Document ] doc The document to pluck from. # @param [ [ String | Symbol ]... ] *fields Field(s) to pluck. # # @return [ Object | Array ] The plucked values. diff --git a/lib/mongoid/contextual/mongo.rb b/lib/mongoid/contextual/mongo.rb index 23d12e3fe..1c967fd42 100644 --- a/lib/mongoid/contextual/mongo.rb +++ b/lib/mongoid/contextual/mongo.rb @@ -204,7 +204,7 @@ def explain # from before or after update. # @option options [ true | false ] :upsert Create the document if it doesn't exist. # - # @return [ Document ] The result of the command. + # @return [ Mongoid::Document ] The result of the command. def find_one_and_update(update, options = {}) if doc = view.find_one_and_update(update, options) Factory.from_db(klass, doc) @@ -224,7 +224,7 @@ def find_one_and_update(update, options = {}) # from before or after update. # @option options [ true | false ] :upsert Create the document if it doesn't exist. # - # @return [ Document ] The result of the command. + # @return [ Mongoid::Document ] The result of the command. def find_one_and_replace(replacement, options = {}) if doc = view.find_one_and_replace(replacement, options) Factory.from_db(klass, doc) @@ -237,7 +237,7 @@ def find_one_and_replace(replacement, options = {}) # @example Execute the command. # context.find_one_and_delete # - # @return [ Document ] The result of the command. + # @return [ Mongoid::Document ] The result of the command. def find_one_and_delete if doc = view.find_one_and_delete Factory.from_db(klass, doc) @@ -283,7 +283,7 @@ def geo_near(coordinates) # @example Create the new context. # Mongo.new(criteria) # - # @param [ Criteria ] criteria The criteria. + # @param [ Mongoid::Criteria ] criteria The criteria. def initialize(criteria) @criteria, @klass = criteria, criteria.klass @collection = @klass.collection @@ -386,7 +386,7 @@ def pick(*fields) # # @param [ Integer | nil ] limit The number of documents to return or nil. # - # @return [ Document | Array ] The list of documents, or one + # @return [ Mongoid::Document | Array ] The list of documents, or one # document if no value was given. def take(limit = nil) if limit @@ -403,7 +403,7 @@ def take(limit = nil) # @example Take a document # context.take! # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -563,7 +563,7 @@ def update_all(attributes = nil, opts = {}) # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document | nil ] The first document or nil if none is found. + # @return [ Mongoid::Document | nil ] The first document or nil if none is found. def first(limit = nil) if limit.nil? retrieve_nth(0) @@ -585,7 +585,7 @@ def first(limit = nil) # and have no sort defined on the criteria, use #take! instead. # Be aware that #take! won't guarantee order. # - # @return [ Document ] The first document. + # @return [ Mongoid::Document ] The first document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -606,7 +606,7 @@ def first! # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document | nil ] The last document or nil if none is found. + # @return [ Mongoid::Document | nil ] The last document or nil if none is found. def last(limit = nil) if limit.nil? retrieve_nth_to_last(0) @@ -627,7 +627,7 @@ def last(limit = nil) # and have no sort defined on the criteria, use #take! instead. # Be aware that #take! won't guarantee order. # - # @return [ Document ] The last document. + # @return [ Mongoid::Document ] The last document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -640,7 +640,7 @@ def last! # @example Get the second document. # context.second # - # @return [ Document | nil ] The second document or nil if none is found. + # @return [ Mongoid::Document | nil ] The second document or nil if none is found. def second retrieve_nth(1) end @@ -651,7 +651,7 @@ def second # @example Get the second document. # context.second! # - # @return [ Document ] The second document. + # @return [ Mongoid::Document ] The second document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -664,7 +664,7 @@ def second! # @example Get the third document. # context.third # - # @return [ Document | nil ] The third document or nil if none is found. + # @return [ Mongoid::Document | nil ] The third document or nil if none is found. def third retrieve_nth(2) end @@ -675,7 +675,7 @@ def third # @example Get the third document. # context.third! # - # @return [ Document ] The third document. + # @return [ Mongoid::Document ] The third document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -688,7 +688,7 @@ def third! # @example Get the fourth document. # context.fourth # - # @return [ Document | nil ] The fourth document or nil if none is found. + # @return [ Mongoid::Document | nil ] The fourth document or nil if none is found. def fourth retrieve_nth(3) end @@ -699,7 +699,7 @@ def fourth # @example Get the fourth document. # context.fourth! # - # @return [ Document ] The fourth document. + # @return [ Mongoid::Document ] The fourth document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -712,7 +712,7 @@ def fourth! # @example Get the fifth document. # context.fifth # - # @return [ Document | nil ] The fifth document or nil if none is found. + # @return [ Mongoid::Document | nil ] The fifth document or nil if none is found. def fifth retrieve_nth(4) end @@ -723,7 +723,7 @@ def fifth # @example Get the fifth document. # context.fifth! # - # @return [ Document ] The fifth document. + # @return [ Mongoid::Document ] The fifth document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -737,7 +737,7 @@ def fifth! # @example Get the second to last document. # context.second_to_last # - # @return [ Document | nil ] The second to last document or nil if none + # @return [ Mongoid::Document | nil ] The second to last document or nil if none # is found. def second_to_last retrieve_nth_to_last(1) @@ -749,7 +749,7 @@ def second_to_last # @example Get the second to last document. # context.second_to_last! # - # @return [ Document ] The second to last document. + # @return [ Mongoid::Document ] The second to last document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -763,7 +763,7 @@ def second_to_last! # @example Get the third to last document. # context.third_to_last # - # @return [ Document | nil ] The third to last document or nil if none + # @return [ Mongoid::Document | nil ] The third to last document or nil if none # is found. def third_to_last retrieve_nth_to_last(2) @@ -775,7 +775,7 @@ def third_to_last # @example Get the third to last document. # context.third_to_last! # - # @return [ Document ] The third to last document. + # @return [ Mongoid::Document ] The third to last document. # # @raises [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -866,7 +866,7 @@ def inverse_sorting # If the documents have been already preloaded by `Document::Loader` # instance, they will be used. # - # @return [ Array | Mongo::Collection::View ] The docs to iterate. + # @return [ Array | Mongo::Collection::View ] The docs to iterate. # # @api private def documents_for_iteration @@ -895,7 +895,7 @@ def documents_for_iteration # ... # end # - # @param [ Document ] document The document to yield to. + # @param [ Mongoid::Document ] document The document to yield to. def yield_document(document, &block) doc = document.respond_to?(:_id) ? document : Factory.from_db(klass, document, criteria) @@ -1027,7 +1027,7 @@ def demongoize_with_field(field, value, is_translation) # Process the raw documents retrieved for #first/#last. # - # @return [ Array | Document ] The list of documents or a + # @return [ Array | Mongoid::Document ] The list of documents or a # single document. def process_raw_docs(raw_docs, limit) docs = raw_docs.map do |d| diff --git a/lib/mongoid/contextual/none.rb b/lib/mongoid/contextual/none.rb index 8b8773777..239f9f76a 100644 --- a/lib/mongoid/contextual/none.rb +++ b/lib/mongoid/contextual/none.rb @@ -115,7 +115,7 @@ def tally(_field) # @example Create the new context. # Null.new(criteria) # - # @param [ Criteria ] criteria The criteria. + # @param [ Mongoid::Criteria ] criteria The criteria. def initialize(criteria) @criteria, @klass = criteria, criteria.klass end diff --git a/lib/mongoid/copyable.rb b/lib/mongoid/copyable.rb index 2ab4709f0..8079832ad 100644 --- a/lib/mongoid/copyable.rb +++ b/lib/mongoid/copyable.rb @@ -19,7 +19,7 @@ module Copyable # @example Clone the document. # document.clone # - # @return [ Document ] The new document. + # @return [ Mongoid::Document ] The new document. def clone # @note This next line is here to address #2704, even though having an # _id and id field in the document would cause problems with Mongoid @@ -39,7 +39,7 @@ def clone # @param [ Class ] klass The class of the document to create. # @param [ Hash ] attrs The hash of the attributes. # - # @return [ Document ] The new document. + # @return [ Mongoid::Document ] The new document. def self.clone_with_hash(klass, attrs) dynamic_attrs = {} _attribute_names = klass.attribute_names diff --git a/lib/mongoid/criteria.rb b/lib/mongoid/criteria.rb index 27182e18e..cf6181961 100644 --- a/lib/mongoid/criteria.rb +++ b/lib/mongoid/criteria.rb @@ -93,7 +93,7 @@ def ==(other) # @param &block Optional block to pass. # @yield [ Object ] Yields each enumerable element to the block. # - # @return [ Document | Array | nil ] A document or matching documents. + # @return [ Mongoid::Document | Array | nil ] A document or matching documents. # # @raise Errors::DocumentNotFound If the parameters were _id values and # not all documents are found and the +raise_not_found_error+ @@ -125,7 +125,7 @@ def as_json(options = nil) # @example Get the documents. # criteria.documents # - # @return [ Array ] The documents. + # @return [ Array ] The documents. def documents @documents ||= [] end @@ -134,9 +134,9 @@ def documents # # @example Set the documents. # - # @param [ Array ] docs The embedded documents. + # @param [ Array ] docs The embedded documents. # - # @return [ Array ] The embedded documents. + # @return [ Array ] The embedded documents. def documents=(docs) @documents = docs end @@ -170,7 +170,7 @@ def extract_id # # @param [ Hash ] extras The extra driver options. # - # @return [ Criteria ] The cloned criteria. + # @return [ Mongoid::Criteria ] The cloned criteria. def extras(extras) crit = clone crit.options.merge!(extras) @@ -198,7 +198,7 @@ def field_list # @example Freeze the criteria. # criteria.freeze # - # @return [ Criteria ] The frozen criteria. + # @return [ Mongoid::Criteria ] The frozen criteria. def freeze context and inclusions and super end @@ -233,9 +233,9 @@ def initialize(klass) # order_by: { name: 1 } # }) # - # @param [ Criteria ] other The other criterion to merge with. + # @param [ Mongoid::Criteria ] other The other criterion to merge with. # - # @return [ Criteria ] A cloned self. + # @return [ Mongoid::Criteria ] A cloned self. def merge(other) crit = clone crit.merge!(other) @@ -247,9 +247,9 @@ def merge(other) # @example Merge another criteria into this criteria. # criteria.merge(Person.where(name: "bob")) # - # @param [ Criteria ] other The criteria to merge in. + # @param [ Mongoid::Criteria ] other The criteria to merge in. # - # @return [ Criteria ] The merged criteria. + # @return [ Mongoid::Criteria ] The merged criteria. def merge!(other) criteria = other.to_criteria selector.merge!(criteria.selector) @@ -266,7 +266,7 @@ def merge!(other) # @example Return a none criteria. # criteria.none # - # @return [ Criteria ] The none criteria. + # @return [ Mongoid::Criteria ] The none criteria. def none @none = true and self end @@ -288,7 +288,7 @@ def empty_and_chainable? # # @param [ [ Symbol | Array ]... ] *args The field name(s). # - # @return [ Criteria ] The cloned criteria. + # @return [ Mongoid::Criteria ] The cloned criteria. def only(*args) args = args.flatten return clone if args.empty? @@ -308,7 +308,7 @@ def only(*args) # # @param [ Hash ] value The mode preference. # - # @return [ Criteria ] The cloned criteria. + # @return [ Mongoid::Criteria ] The cloned criteria. def read(value = nil) clone.tap do |criteria| criteria.options.merge!(read: value) @@ -322,7 +322,7 @@ def read(value = nil) # # @param [ Symbol... ] *args The field name(s). # - # @return [ Criteria ] The cloned criteria. + # @return [ Mongoid::Criteria ] The cloned criteria. def without(*args) args -= id_fields super(*args) @@ -348,7 +348,7 @@ def respond_to?(name, include_private = false) # @example Convert to a criteria. # criteria.to_criteria # - # @return [ Criteria ] self. + # @return [ Mongoid::Criteria ] self. def to_criteria self end @@ -372,7 +372,7 @@ def to_proc # # @param [ Array ] types The types to match against. # - # @return [ Criteria ] The cloned criteria. + # @return [ Mongoid::Criteria ] The cloned criteria. def type(types) any_in(self.discriminator_key.to_sym => Array(types)) end @@ -393,7 +393,7 @@ def type(types) # @raise [ UnsupportedJavascript ] If provided a string and the criteria # is embedded. # - # @return [ Criteria ] The cloned selectable. + # @return [ Mongoid::Criteria ] The cloned selectable. def where(*args) # Historically this method required exactly one argument. # As of https://jira.mongodb.org/browse/MONGOID-4804 it also accepts @@ -419,7 +419,7 @@ def where(*args) # @example Get the criteria without options. # criteria.without_options # - # @return [ Criteria ] The cloned criteria. + # @return [ Mongoid::Criteria ] The cloned criteria. def without_options crit = clone crit.options.clear @@ -437,7 +437,7 @@ def without_options # @param [ String ] javascript The javascript to execute in the $where. # @param [ Hash ] scope The scope for the code. # - # @return [ Criteria ] The criteria. + # @return [ Mongoid::Criteria ] The criteria. def for_js(javascript, scope = {}) code = if scope.empty? # CodeWithScope is not supported for $where as of MongoDB 4.4 @@ -458,7 +458,7 @@ def for_js(javascript, scope = {}) # @example Check for missing documents. # criteria.check_for_missing_documents!([], [ 1 ]) # - # @param [ Array ] result The result. + # @param [ Array ] result The result. # @param [ Array ] ids The ids. # # @raise [ Errors::DocumentNotFound ] If none are found and raising an @@ -480,7 +480,7 @@ def check_for_missing_documents!(result, ids) # @example Dup a criteria. # criteria.dup # - # @param [ Criteria ] other The criteria getting cloned. + # @param [ Mongoid::Criteria ] other The criteria getting cloned. # # @return [ nil ] nil. def initialize_copy(other) diff --git a/lib/mongoid/criteria/findable.rb b/lib/mongoid/criteria/findable.rb index 2614c2fbe..8525a6d2b 100644 --- a/lib/mongoid/criteria/findable.rb +++ b/lib/mongoid/criteria/findable.rb @@ -17,7 +17,7 @@ module Findable # # @raise [ Errors::DocumentNotFound ] If nothing returned. # - # @return [ Document | Array ] The document(s). + # @return [ Mongoid::Document | Array ] The document(s). def execute_or_raise(ids, multi) result = multiple_from_db(ids) check_for_missing_documents!(result, ids) @@ -37,7 +37,7 @@ def execute_or_raise(ids, multi) # # @param [ [ Object | Array ]... ] *args The id(s) to find. # - # @return [ Document | Array ] The matching document(s). + # @return [ Mongoid::Document | Array ] The matching document(s). def find(*args) ids = args.__find_args__ raise_invalid if ids.any?(&:nil?) @@ -54,7 +54,7 @@ def find(*args) # # @param [ Array ] ids The array of ids. # - # @return [ Criteria ] The cloned criteria. + # @return [ Mongoid::Criteria ] The cloned criteria. def for_ids(ids) ids = mongoize_ids(ids) if ids.size > 1 @@ -72,7 +72,7 @@ def for_ids(ids) # # @param [ Array ] ids The searched ids. # - # @return [ Array ] The found documents. + # @return [ Array ] The found documents. def multiple_from_db(ids) return entries if embedded? ids = mongoize_ids(ids) @@ -102,7 +102,7 @@ def id_finder # # @param [ Array ] ids The ids to fetch with. # - # @return [ Array ] The matching documents. + # @return [ Array ] The matching documents. def from_database(ids) from_database_selector(ids).entries end diff --git a/lib/mongoid/criteria/includable.rb b/lib/mongoid/criteria/includable.rb index e948a6787..c10518ff6 100644 --- a/lib/mongoid/criteria/includable.rb +++ b/lib/mongoid/criteria/includable.rb @@ -24,7 +24,7 @@ module Includable # @param [ [ Symbol | Hash ]... ] *relations The names of the association(s) # to eager load. # - # @return [ Criteria ] The cloned criteria. + # @return [ Mongoid::Criteria ] The cloned criteria. def includes(*relations) extract_includes_list(klass, nil, relations) clone diff --git a/lib/mongoid/criteria/modifiable.rb b/lib/mongoid/criteria/modifiable.rb index e464cf0e7..7b9bc7013 100644 --- a/lib/mongoid/criteria/modifiable.rb +++ b/lib/mongoid/criteria/modifiable.rb @@ -21,7 +21,7 @@ module Modifiable # @example Build with selectors getting ignored. # Person.where(:age.gt => 5).build # - # @return [ Document ] A non-persisted document. + # @return [ Mongoid::Document ] A non-persisted document. def build(attrs = {}, &block) create_document(:new, attrs, &block) end @@ -36,7 +36,7 @@ def build(attrs = {}, &block) # @example Create with selectors getting ignored. # Person.where(:age.gt => 5).create # - # @return [ Document ] A newly created document. + # @return [ Mongoid::Document ] A newly created document. def create(attrs = {}, &block) create_document(:create, attrs, &block) end @@ -53,7 +53,7 @@ def create(attrs = {}, &block) # # @raise [ Errors::Validations ] on a validation error. # - # @return [ Document ] A newly created document. + # @return [ Mongoid::Document ] A newly created document. def create!(attrs = {}, &block) create_document(:create!, attrs, &block) end @@ -82,7 +82,7 @@ def create_with(attrs = {}) # # @param [ Hash ] attrs The attributes to check. # - # @return [ Document ] A matching or newly created document. + # @return [ Mongoid::Document ] A matching or newly created document. def find_or_create_by(attrs = {}, &block) find_or(:create, attrs, &block) end @@ -98,7 +98,7 @@ def find_or_create_by(attrs = {}, &block) # # @raise [ Errors::Validations ] on validation error. # - # @return [ Document ] A matching or newly created document. + # @return [ Mongoid::Document ] A matching or newly created document. def find_or_create_by!(attrs = {}, &block) find_or(:create!, attrs, &block) end @@ -111,7 +111,7 @@ def find_or_create_by!(attrs = {}, &block) # # @param [ Hash ] attrs The attributes to check. # - # @return [ Document ] A matching or newly initialized document. + # @return [ Mongoid::Document ] A matching or newly initialized document. def find_or_initialize_by(attrs = {}, &block) find_or(:new, attrs, &block) end @@ -124,7 +124,7 @@ def find_or_initialize_by(attrs = {}, &block) # # @param [ Hash ] attrs The additional attributes to add. # - # @return [ Document ] A matching or newly created document. + # @return [ Mongoid::Document ] A matching or newly created document. def first_or_create(attrs = nil, &block) first_or(:create, attrs, &block) end @@ -138,7 +138,7 @@ def first_or_create(attrs = nil, &block) # # @param [ Hash ] attrs The additional attributes to add. # - # @return [ Document ] A matching or newly created document. + # @return [ Mongoid::Document ] A matching or newly created document. def first_or_create!(attrs = nil, &block) first_or(:create!, attrs, &block) end @@ -151,7 +151,7 @@ def first_or_create!(attrs = nil, &block) # # @param [ Hash ] attrs The additional attributes to add. # - # @return [ Document ] A matching or newly initialized document. + # @return [ Mongoid::Document ] A matching or newly initialized document. def first_or_initialize(attrs = nil, &block) first_or(:new, attrs, &block) end @@ -169,7 +169,7 @@ def first_or_initialize(attrs = nil, &block) # @param [ Symbol ] method Either :new or :create. # @param [ Hash ] attrs Additional attributes to use. # - # @return [ Document ] The new or saved document. + # @return [ Mongoid::Document ] The new or saved document. def create_document(method, attrs = nil, &block) attrs = (create_attrs || {}).merge(attrs || {}) attributes = selector.reduce(attrs) do |hash, (key, value)| @@ -199,7 +199,7 @@ def create_document(method, attrs = nil, &block) # @param [ Symbol ] method The method to invoke. # @param [ Hash ] attrs The attributes to query or set. # - # @return [ Document ] The first or new document. + # @return [ Mongoid::Document ] The first or new document. def find_or(method, attrs = {}, &block) where(attrs).first || send(method, attrs, &block) end @@ -214,7 +214,7 @@ def find_or(method, attrs = {}, &block) # @param [ Symbol ] method The method to invoke. # @param [ Hash ] attrs The attributes to query or set. # - # @return [ Document ] The first or new document. + # @return [ Mongoid::Document ] The first or new document. def first_or(method, attrs = {}, &block) first || create_document(method, attrs, &block) end diff --git a/lib/mongoid/criteria/queryable.rb b/lib/mongoid/criteria/queryable.rb index d02662dc6..aa62154c8 100644 --- a/lib/mongoid/criteria/queryable.rb +++ b/lib/mongoid/criteria/queryable.rb @@ -79,7 +79,7 @@ def initialize(aliases = {}, serializers = {}, associations = {}, aliased_associ # @example Handle copy initialization. # queryable.initialize_copy(criteria) # - # @param [ Queryable ] other The original copy. + # @param [ Mongoid::Criteria::Queryable ] other The original copy. def initialize_copy(other) @options = other.options.__deep_copy__ @selector = other.selector.__deep_copy__ diff --git a/lib/mongoid/criteria/queryable/mergeable.rb b/lib/mongoid/criteria/queryable/mergeable.rb index 3d96d0b23..7aa030b2f 100644 --- a/lib/mongoid/criteria/queryable/mergeable.rb +++ b/lib/mongoid/criteria/queryable/mergeable.rb @@ -45,7 +45,7 @@ def union # @example Reset the strategies. # mergeable.reset_strategies! # - # @return [ Criteria ] self. + # @return [ Mongoid::Criteria ] self. def reset_strategies! self.strategy = nil self.negating = nil @@ -57,7 +57,7 @@ def reset_strategies! # @param [ Hash ] criterion The criterion to add to the criteria. # @param [ String ] operator The MongoDB operator. # - # @return [ Criteria ] The resulting criteria. + # @return [ Mongoid::Criteria ] The resulting criteria. def and_with_operator(criterion, operator) crit = self if criterion @@ -151,7 +151,7 @@ def __intersect__(criterion, operator) # @example Add the criterion. # mergeable.__multi__([ 1, 2 ], "$in") # - # @param [ Array ] criteria Multiple key/value pair + # @param [ Array ] criteria Multiple key/value pair # matches or Criteria objects. # @param [ String ] operator The MongoDB operator. # @@ -335,7 +335,7 @@ def __multi__(criteria, operator) # @example Add the criterion. # mergeable.__override__([ 1, 2 ], "$in") # - # @param [ Hash | Criteria ] criterion The criteria. + # @param [ Hash | Mongoid::Criteria ] criterion The criteria. # @param [ String ] operator The MongoDB operator. # # @return [ Mergeable ] The new mergeable. diff --git a/lib/mongoid/criteria/queryable/optional.rb b/lib/mongoid/criteria/queryable/optional.rb index 8477e8e15..0272b4ede 100644 --- a/lib/mongoid/criteria/queryable/optional.rb +++ b/lib/mongoid/criteria/queryable/optional.rb @@ -333,7 +333,7 @@ def add_sort_option(options, field, direction) # # @param [ Object... ] *args The options. # - # @return [ Queryable ] The cloned queryable. + # @return [ Mongoid::Criteria::Queryable ] The cloned queryable. def option(*args) clone.tap do |query| unless args.compact.empty? diff --git a/lib/mongoid/criteria/queryable/selectable.rb b/lib/mongoid/criteria/queryable/selectable.rb index 146015e53..ba0bb0a6b 100644 --- a/lib/mongoid/criteria/queryable/selectable.rb +++ b/lib/mongoid/criteria/queryable/selectable.rb @@ -69,7 +69,7 @@ def all(*criteria) # @example Add the criterion. # selectable.and({ field: value }, { other: value }) # - # @param [ [ Hash | Criteria | Array ]... ] *criteria + # @param [ [ Hash | Mongoid::Criteria | Array ]... ] *criteria # Multiple key/value pair matches or Criteria objects that all must # match to return results. # @@ -517,7 +517,7 @@ def nin(condition) # @example Add the $nor selection. # selectable.nor(field: 1, field: 2) # - # @param [ [ Hash | Criteria | Array ]... ] *criteria + # @param [ [ Hash | Mongoid::Criteria | Array ]... ] *criteria # Multiple key/value pair matches or Criteria objects. # # @return [ Selectable ] The new selectable. @@ -546,7 +546,7 @@ def negating? # @example Execute a $not in a where query. # selectable.where(:field.not => /Bob/) # - # @param [ [ Hash | Criteria ]... ] *criteria The key/value pair + # @param [ [ Hash | Mongoid::Criteria ]... ] *criteria The key/value pair # matches or Criteria objects to negate. # # @return [ Selectable ] The new selectable. @@ -593,7 +593,7 @@ def not(*criteria) # @example Exclude multiple criteria as an array. # selectable.none_of([{ name: /Bob/ }, { country: "USA" }]) # - # @param [ [ Hash | Criteria ]... ] *criteria The key/value pair + # @param [ [ Hash | Mongoid::Criteria ]... ] *criteria The key/value pair # matches or Criteria objects to negate. # # @return [ Selectable ] The new selectable. @@ -635,7 +635,7 @@ def none_of(*criteria) # @example Same as previous example, also deprecated. # selectable.or([{field: 1}], [{field: 2}]) # - # @param [ [ Hash | Criteria | Array ]... ] *criteria + # @param [ [ Hash | Mongoid::Criteria | Array ]... ] *criteria # Multiple key/value pair matches or Criteria objects, or arrays # thereof. Passing arrays is deprecated. # @@ -665,7 +665,7 @@ def or(*criteria) # @example Same as previous example, also deprecated. # selectable.any_of([{field: 1}], [{field: 2}]) # - # @param [ [ Hash | Criteria | Array ]... ] *criteria + # @param [ [ Hash | Mongoid::Criteria | Array ]... ] *criteria # Multiple key/value pair matches or Criteria objects, or arrays # thereof. Passing arrays is deprecated. # diff --git a/lib/mongoid/criteria/scopable.rb b/lib/mongoid/criteria/scopable.rb index 9e769192b..bf44af4dd 100644 --- a/lib/mongoid/criteria/scopable.rb +++ b/lib/mongoid/criteria/scopable.rb @@ -13,7 +13,7 @@ module Scopable # @example Apply the default scope. # criteria.apply_default_scope # - # @return [ Criteria ] The criteria. + # @return [ Mongoid::Criteria ] The criteria. def apply_default_scope klass.without_default_scope do merge!(klass.default_scoping.call) @@ -28,9 +28,9 @@ def apply_default_scope # argument is nil, the receiver is returned without modification, # otherwise a new criteria object is returned. # - # @param [ Proc | Symbol | Criteria | nil ] scope The scope to apply. + # @param [ Proc | Symbol | Mongoid::Criteria | nil ] scope The scope to apply. # - # @return [ Criteria ] The criteria with the scope applied. + # @return [ Mongoid::Criteria ] The criteria with the scope applied. # # @api private def apply_scope(scope) @@ -52,9 +52,9 @@ def apply_scope(scope) # @example Remove the scoping. # criteria.remove_scoping(other) # - # @param [ Criteria ] other The other criteria. + # @param [ Mongoid::Criteria ] other The other criteria. # - # @return [ Criteria ] The criteria with scoping removed. + # @return [ Mongoid::Criteria ] The criteria with scoping removed. def remove_scoping(other) if other reject_matching(other, :selector, :options) @@ -72,7 +72,7 @@ def remove_scoping(other) # # @param [ Hash ] options Additional query options. # - # @return [ Criteria ] The scoped criteria. + # @return [ Mongoid::Criteria ] The scoped criteria. def scoped(options = nil) crit = clone crit.options.merge!(options || {}) @@ -97,7 +97,7 @@ def scoped? # @example Clear all scoping from the criteria. # criteria.unscoped # - # @return [ Criteria ] The unscoped criteria. + # @return [ Mongoid::Criteria ] The unscoped criteria. def unscoped crit = clone unless unscoped? @@ -147,7 +147,7 @@ def scoping_options=(options) # @example Get the criteria with the default scope. # criteria.with_default_scope # - # @return [ Criteria ] The criteria. + # @return [ Mongoid::Criteria ] The criteria. def with_default_scope crit = clone if klass.default_scopable? && !unscoped? && !scoped? diff --git a/lib/mongoid/document.rb b/lib/mongoid/document.rb index 8a0b17db1..5357cf2a0 100644 --- a/lib/mongoid/document.rb +++ b/lib/mongoid/document.rb @@ -46,7 +46,7 @@ module Document # @example Freeze the document # document.freeze # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def freeze as_attributes.freeze and self end @@ -99,7 +99,7 @@ def identity # # @param [ Hash ] attrs The attributes to set up the document with. # - # @return [ Document ] A new document. + # @return [ Mongoid::Document ] A new document. def initialize(attrs = nil, &block) construct_document(attrs, execute_callbacks: true, &block) end @@ -173,7 +173,7 @@ def as_json(options = nil) # # @param [ Class ] klass The class to become. # - # @return [ Document ] An instance of the specified class. + # @return [ Mongoid::Document ] An instance of the specified class. def becomes(klass) unless klass.include?(Mongoid::Document) raise ArgumentError, "A class which includes Mongoid::Document is expected" @@ -211,7 +211,7 @@ def becomes(klass) # @param [ true | false ] execute_callbacks Flag specifies whether callbacks # should be run. # - # @return [ Document ] A new document. + # @return [ Mongoid::Document ] A new document. # # @api private def construct_document(attrs = nil, execute_callbacks: true) @@ -293,7 +293,7 @@ module ClassMethods # @param [ true | false ] execute_callbacks Flag specifies whether callbacks # should be run. # - # @return [ Document ] A new document. + # @return [ Mongoid::Document ] A new document. def instantiate(attrs = nil, selected_fields = nil, &block) instantiate_document(attrs, selected_fields, execute_callbacks: true, &block) end @@ -306,7 +306,7 @@ def instantiate(attrs = nil, selected_fields = nil, &block) # @param [ true | false ] execute_callbacks Flag specifies whether callbacks # should be run. # - # @return [ Document ] A new document. + # @return [ Mongoid::Document ] A new document. # # @api private def instantiate_document(attrs = nil, selected_fields = nil, execute_callbacks: true) @@ -336,7 +336,7 @@ def instantiate_document(attrs = nil, selected_fields = nil, execute_callbacks: # @param [ true | false ] execute_callbacks Flag specifies whether callbacks # should be run. # - # @return [ Document ] A new document. + # @return [ Mongoid::Document ] A new document. # # @api private def construct_document(attrs = nil, execute_callbacks: true) diff --git a/lib/mongoid/equality.rb b/lib/mongoid/equality.rb index f79446b91..ba758fbad 100644 --- a/lib/mongoid/equality.rb +++ b/lib/mongoid/equality.rb @@ -13,7 +13,7 @@ module Equality # @example Compare two documents. # person <=> other_person # - # @param [ Document ] other The document to compare with. + # @param [ Mongoid::Document ] other The document to compare with. # # @return [ Integer ] -1, 0, 1. def <=>(other) @@ -26,7 +26,7 @@ def <=>(other) # @example Compare for equality. # document == other # - # @param [ Document | Object ] other The other object to compare with. + # @param [ Mongoid::Document | Object ] other The other object to compare with. # # @return [ true | false ] True if the ids are equal, false if not. def ==(other) @@ -39,7 +39,7 @@ def ==(other) # @example Perform equality checking. # document.eql?(other) # - # @param [ Document | Object ] other The object to check against. + # @param [ Mongoid::Document | Object ] other The object to check against. # # @return [ true | false ] True if equal, false if not. def eql?(other) @@ -52,7 +52,7 @@ module ClassMethods # @example Compare the classes. # document === other # - # @param [ Document | Object ] other The other object to compare with. + # @param [ Mongoid::Document | Object ] other The other object to compare with. # # @return [ true | false ] True if the classes are equal, false if not. def ===(other) diff --git a/lib/mongoid/errors/delete_restriction.rb b/lib/mongoid/errors/delete_restriction.rb index 91b897c82..71074747c 100644 --- a/lib/mongoid/errors/delete_restriction.rb +++ b/lib/mongoid/errors/delete_restriction.rb @@ -9,7 +9,7 @@ class DeleteRestriction < MongoidError # Create the new callbacks error. # - # @param [ Document ] document The document that was attempted to be + # @param [ Mongoid::Document ] document The document that was attempted to be # destroyed. # @param [ Symbol ] association_name The name of the dependent # association that prevents the document from being deleted. diff --git a/lib/mongoid/extensions/hash.rb b/lib/mongoid/extensions/hash.rb index d2fe50b8c..dba623641 100644 --- a/lib/mongoid/extensions/hash.rb +++ b/lib/mongoid/extensions/hash.rb @@ -172,7 +172,7 @@ def resizable? # @example Convert the hash to a criteria. # { klass: Band, where: { name: "Depeche Mode" }.to_criteria # - # @return [ Criteria ] The criteria. + # @return [ Mongoid::Criteria ] The criteria. def to_criteria criteria = Criteria.new(delete(:klass) || delete("klass")) each_pair do |method, args| diff --git a/lib/mongoid/factory.rb b/lib/mongoid/factory.rb index 6daf7bf32..8d4fcb018 100644 --- a/lib/mongoid/factory.rb +++ b/lib/mongoid/factory.rb @@ -23,7 +23,7 @@ module Factory # @param [ true | false ] execute_callbacks Flag specifies whether callbacks # should be run. # - # @return [ Document ] The instantiated document. + # @return [ Mongoid::Document ] The instantiated document. def build(klass, attributes = nil) execute_build(klass, attributes, execute_callbacks: true) end @@ -35,7 +35,7 @@ def build(klass, attributes = nil) # @param [ true | false ] execute_callbacks Flag specifies whether callbacks # should be run. # - # @return [ Document ] The instantiated document. + # @return [ Mongoid::Document ] The instantiated document. # # @api private def execute_build(klass, attributes = nil, execute_callbacks: true) @@ -69,12 +69,12 @@ def execute_build(klass, attributes = nil, execute_callbacks: true) # # @param [ Class ] klass The class to instantiate from if _type is not present. # @param [ Hash ] attributes The document attributes. - # @param [ Criteria ] criteria Optional criteria object. + # @param [ Mongoid::Criteria ] criteria Optional criteria object. # @param [ Hash ] selected_fields Fields which were retrieved via # #only. If selected_fields are specified, fields not listed in it # will not be accessible in the returned document. # - # @return [ Document ] The instantiated document. + # @return [ Mongoid::Document ] The instantiated document. def from_db(klass, attributes = nil, criteria = nil, selected_fields = nil) execute_from_db(klass, attributes, criteria, selected_fields, execute_callbacks: true) end @@ -83,7 +83,7 @@ def from_db(klass, attributes = nil, criteria = nil, selected_fields = nil) # # @param [ Class ] klass The class to instantiate from if _type is not present. # @param [ Hash ] attributes The document attributes. - # @param [ Criteria ] criteria Optional criteria object. + # @param [ Mongoid::Criteria ] criteria Optional criteria object. # @param [ Hash ] selected_fields Fields which were retrieved via # #only. If selected_fields are specified, fields not listed in it # will not be accessible in the returned document. @@ -94,7 +94,7 @@ def from_db(klass, attributes = nil, criteria = nil, selected_fields = nil) # later time. Use this option to defer callback execution until the # entire object graph containing embedded associations is constructed. # - # @return [ Document ] The instantiated document. + # @return [ Mongoid::Document ] The instantiated document. # # @api private def execute_from_db(klass, attributes = nil, criteria = nil, selected_fields = nil, execute_callbacks: true) diff --git a/lib/mongoid/fields/foreign_key.rb b/lib/mongoid/fields/foreign_key.rb index b67ac7ec8..281e832eb 100644 --- a/lib/mongoid/fields/foreign_key.rb +++ b/lib/mongoid/fields/foreign_key.rb @@ -15,7 +15,7 @@ class ForeignKey < Standard # # @todo: Durran: Refactor, big time. # - # @param [ Document ] document The document to add to. + # @param [ Mongoid::Document ] document The document to add to. # @param [ String ] name The name of the field. # @param [ String ] key The atomic location of the field. # @param [ Hash ] mods The current modifications. @@ -129,7 +129,7 @@ def resizable? # @example Eval the default proc. # field.evaluate_default_proc(band) # - # @param [ Document ] doc The document. + # @param [ Mongoid::Document ] doc The document. # # @return [ Object ] The called proc. def evaluate_default_proc(doc) diff --git a/lib/mongoid/fields/standard.rb b/lib/mongoid/fields/standard.rb index 7b9551606..66d351fbd 100644 --- a/lib/mongoid/fields/standard.rb +++ b/lib/mongoid/fields/standard.rb @@ -20,7 +20,7 @@ class Standard # @example Add the atomic changes. # field.add_atomic_changes(doc, "key", {}, [], []) # - # @param [ Document ] document The document to add to. + # @param [ Mongoid::Document ] document The document to add to. # @param [ String ] name The name of the field. # @param [ String ] key The atomic location of the field. # @param [ Hash ] mods The current modifications. @@ -36,7 +36,7 @@ def add_atomic_changes(document, name, key, mods, new, old) # @example Evaluate the default value. # field.eval_default(document) # - # @param [ Document ] doc The document the field belongs to. + # @param [ Mongoid::Document ] doc The document the field belongs to. # # @return [ Object ] The serialized default value. def eval_default(doc) @@ -202,7 +202,7 @@ def included?(fields) # @example Get the evaluated default. # field.evaluated_default. # - # @param [ Document ] doc The doc being applied to. + # @param [ Mongoid::Document ] doc The doc being applied to. # # @return [ Object ] The default value. def evaluated_default(doc) @@ -219,7 +219,7 @@ def evaluated_default(doc) # @example Eval the default proc. # field.evaluate_default_proc(band) # - # @param [ Document ] doc The document. + # @param [ Mongoid::Document ] doc The document. # # @return [ Object ] The called proc. def evaluate_default_proc(doc) diff --git a/lib/mongoid/findable.rb b/lib/mongoid/findable.rb index f56aa13a3..136404f0a 100644 --- a/lib/mongoid/findable.rb +++ b/lib/mongoid/findable.rb @@ -161,7 +161,7 @@ def exists?(id_or_conditions = :none) # # @param [ [ Object | Array ]... ] *args The id(s) to find. # - # @return [ Document | Array | nil ] A document or matching documents. + # @return [ Mongoid::Document | Array | nil ] A document or matching documents. # # @raise Errors::DocumentNotFound If not all documents are found and # the +raise_not_found_error+ Mongoid configuration option is truthy. @@ -187,7 +187,7 @@ def find(*args, &block) # @raise [ Errors::DocumentNotFound ] If no document found # and Mongoid.raise_not_found_error is true. # - # @return [ Document | nil ] A matching document. + # @return [ Mongoid::Document | nil ] A matching document. def find_by(attrs = {}) result = where(attrs).find_first if result.nil? && Mongoid.raise_not_found_error @@ -207,7 +207,7 @@ def find_by(attrs = {}) # # @raise [ Errors::DocumentNotFound ] If no document found. # - # @return [ Document ] A matching document. + # @return [ Mongoid::Document ] A matching document. def find_by!(attrs = {}) result = where(attrs).find_first raise(Errors::DocumentNotFound.new(self, attrs)) unless result @@ -222,7 +222,7 @@ def find_by!(attrs = {}) # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The first matching document. + # @return [ Mongoid::Document ] The first matching document. def first(limit = nil) with_default_scope.first(limit) end @@ -235,7 +235,7 @@ def first(limit = nil) # # @param [ Integer ] limit The number of documents to return. # - # @return [ Document ] The last matching document. + # @return [ Mongoid::Document ] The last matching document. def last(limit = nil) with_default_scope.last(limit) end diff --git a/lib/mongoid/interceptable.rb b/lib/mongoid/interceptable.rb index 77efa0b52..f91b40738 100644 --- a/lib/mongoid/interceptable.rb +++ b/lib/mongoid/interceptable.rb @@ -142,7 +142,7 @@ def run_callbacks(kind, with_children: true, skip_if: nil, &block) # Run the callbacks for embedded documents. # # @param [ Symbol ] kind The type of callback to execute. - # @param [ Array ] children Children to execute callbacks on. If + # @param [ Array ] children Children to execute callbacks on. If # nil, callbacks will be executed on all cascadable children of # the document. # @@ -221,7 +221,7 @@ def before_callback_halted? # # @param [ Symbol ] kind The type of callback. # - # @return [ Array ] The children. + # @return [ Array ] The children. def cascadable_children(kind, children = Set.new) embedded_relations.each_pair do |name, association| next unless association.cascading_callbacks? @@ -247,7 +247,7 @@ def cascadable_children(kind, children = Set.new) # document.cascadable_child?(:update, doc) # # @param [ Symbol ] kind The type of callback. - # @param [ Document ] child The child document. + # @param [ Mongoid::Document ] child The child document. # # @return [ true | false ] If the child should fire the callback. def cascadable_child?(kind, child, association) @@ -265,7 +265,7 @@ def cascadable_child?(kind, child, association) # document.child_callback_type(:update, doc) # # @param [ Symbol ] kind The type of callback. - # @param [ Document ] child The child document + # @param [ Mongoid::Document ] child The child document # # @return [ Symbol ] The name of the callback. def child_callback_type(kind, child) diff --git a/lib/mongoid/matcher.rb b/lib/mongoid/matcher.rb index 0588a8141..7091f1145 100644 --- a/lib/mongoid/matcher.rb +++ b/lib/mongoid/matcher.rb @@ -39,7 +39,7 @@ module Matcher # from and behaves identically to association traversal for the purposes # of, for example, subsequent array element retrieval. # - # @param [ Document | Hash ] document The document to extract from. + # @param [ Mongoid::Document | Hash ] document The document to extract from. # @param [ String ] key The key path to extract. # # @return [ Object | Array ] Field value or values. diff --git a/lib/mongoid/persistable/creatable.rb b/lib/mongoid/persistable/creatable.rb index d276780c8..ab3106cc6 100644 --- a/lib/mongoid/persistable/creatable.rb +++ b/lib/mongoid/persistable/creatable.rb @@ -15,7 +15,7 @@ module Creatable # # @param [ Hash ] options Options to pass to insert. # - # @return [ Document ] The persisted document. + # @return [ Mongoid::Document ] The persisted document. def insert(options = {}) prepare_insert(options) do if embedded? @@ -47,7 +47,7 @@ def atomic_inserts # @example Insert the document as embedded. # document.insert_as_embedded # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def insert_as_embedded raise Errors::NoParent.new(self.class.name) unless _parent if _parent.new_record? @@ -67,7 +67,7 @@ def insert_as_embedded # @example Insert the document as root. # document.insert_as_root # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def insert_as_root collection.insert_one(as_attributes, session: _session) end @@ -98,7 +98,7 @@ def post_process_insert # # @param [ Hash ] options The options. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def prepare_insert(options = {}) raise Errors::ReadonlyDocument.new(self.class) if readonly? && !Mongoid.legacy_readonly return self if performing_validations?(options) && @@ -138,7 +138,7 @@ module ClassMethods # @param [ Hash | Array ] attributes The attributes to create with, or an # Array of multiple attributes for multiple documents. # - # @return [ Document | Array ] The newly created document(s). + # @return [ Mongoid::Document | Array ] The newly created document(s). def create(attributes = nil, &block) _creating do if attributes.is_a?(::Array) @@ -165,7 +165,7 @@ def create(attributes = nil, &block) # @param [ Hash | Array ] attributes The attributes to create with, or an # Array of multiple attributes for multiple documents. # - # @return [ Document | Array ] The newly created document(s). + # @return [ Mongoid::Document | Array ] The newly created document(s). def create!(attributes = nil, &block) _creating do if attributes.is_a?(::Array) diff --git a/lib/mongoid/persistable/incrementable.rb b/lib/mongoid/persistable/incrementable.rb index ec142b79f..90abcc02d 100644 --- a/lib/mongoid/persistable/incrementable.rb +++ b/lib/mongoid/persistable/incrementable.rb @@ -16,7 +16,7 @@ module Incrementable # # @param [ Hash ] increments The field/inc increment pairs. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def inc(increments) prepare_atomic_operation do |ops| process_atomic_operations(increments) do |field, value| diff --git a/lib/mongoid/persistable/logical.rb b/lib/mongoid/persistable/logical.rb index 434ab51e3..01334a219 100644 --- a/lib/mongoid/persistable/logical.rb +++ b/lib/mongoid/persistable/logical.rb @@ -15,7 +15,7 @@ module Logical # # @param [ Hash ] operations The bitwise operations. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def bit(operations) prepare_atomic_operation do |ops| process_atomic_operations(operations) do |field, values| diff --git a/lib/mongoid/persistable/maxable.rb b/lib/mongoid/persistable/maxable.rb index 50f8b17f7..a5a6d63ce 100644 --- a/lib/mongoid/persistable/maxable.rb +++ b/lib/mongoid/persistable/maxable.rb @@ -17,7 +17,7 @@ module Maxable # @param [ Hash ] fields The fields to # set, with corresponding minimum values. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def set_max(fields) prepare_atomic_operation do |ops| process_atomic_operations(fields) do |field, value| diff --git a/lib/mongoid/persistable/minable.rb b/lib/mongoid/persistable/minable.rb index 3ca3b175d..3ad1a4a0a 100644 --- a/lib/mongoid/persistable/minable.rb +++ b/lib/mongoid/persistable/minable.rb @@ -17,7 +17,7 @@ module Minable # @param [ Hash ] fields The fields to # set, with corresponding maximum values. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def set_min(fields) prepare_atomic_operation do |ops| process_atomic_operations(fields) do |field, value| diff --git a/lib/mongoid/persistable/multipliable.rb b/lib/mongoid/persistable/multipliable.rb index 996395760..8efcf6414 100644 --- a/lib/mongoid/persistable/multipliable.rb +++ b/lib/mongoid/persistable/multipliable.rb @@ -16,7 +16,7 @@ module Multipliable # # @param [ Hash ] factors The field/factor multiplier pairs. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def mul(factors) prepare_atomic_operation do |ops| process_atomic_operations(factors) do |field, value| diff --git a/lib/mongoid/persistable/poppable.rb b/lib/mongoid/persistable/poppable.rb index ef31ef6e2..38d5bb773 100644 --- a/lib/mongoid/persistable/poppable.rb +++ b/lib/mongoid/persistable/poppable.rb @@ -20,7 +20,7 @@ module Poppable # # @param [ Hash ] pops The field/value pop operations. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def pop(pops) prepare_atomic_operation do |ops| process_atomic_operations(pops) do |field, value| diff --git a/lib/mongoid/persistable/pullable.rb b/lib/mongoid/persistable/pullable.rb index 5e8ed7040..c7ea8ff29 100644 --- a/lib/mongoid/persistable/pullable.rb +++ b/lib/mongoid/persistable/pullable.rb @@ -16,7 +16,7 @@ module Pullable # # @param [ Hash ] pulls The field/value pull pairs. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def pull(pulls) prepare_atomic_operation do |ops| process_atomic_operations(pulls) do |field, value| @@ -34,7 +34,7 @@ def pull(pulls) # # @param [ Hash ] pulls The pull all operations. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def pull_all(pulls) prepare_atomic_operation do |ops| process_atomic_operations(pulls) do |field, value| diff --git a/lib/mongoid/persistable/pushable.rb b/lib/mongoid/persistable/pushable.rb index 4844b4afd..3316152b5 100644 --- a/lib/mongoid/persistable/pushable.rb +++ b/lib/mongoid/persistable/pushable.rb @@ -15,7 +15,7 @@ module Pushable # # @param [ Hash ] adds The field/value pairs to add. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def add_to_set(adds) prepare_atomic_operation do |ops| process_atomic_operations(adds) do |field, value| @@ -46,7 +46,7 @@ def add_to_set(adds) # # @param [ Hash ] pushes The $push operations. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def push(pushes) prepare_atomic_operation do |ops| process_atomic_operations(pushes) do |field, value| diff --git a/lib/mongoid/persistable/renamable.rb b/lib/mongoid/persistable/renamable.rb index 265b04ba7..7977fdae9 100644 --- a/lib/mongoid/persistable/renamable.rb +++ b/lib/mongoid/persistable/renamable.rb @@ -16,7 +16,7 @@ module Renamable # # @param [ Hash ] renames The rename pairs of old name/new name. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def rename(renames) prepare_atomic_operation do |ops| process_atomic_operations(renames) do |old_field, new_field| diff --git a/lib/mongoid/persistable/settable.rb b/lib/mongoid/persistable/settable.rb index ac8d690cd..c8c164df1 100644 --- a/lib/mongoid/persistable/settable.rb +++ b/lib/mongoid/persistable/settable.rb @@ -43,7 +43,7 @@ module Settable # # @param [ Hash ] setters The field/value pairs to set. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def set(setters) prepare_atomic_operation do |ops| process_atomic_operations(setters) do |field, value| diff --git a/lib/mongoid/persistable/unsettable.rb b/lib/mongoid/persistable/unsettable.rb index 92c797dcc..700301e92 100644 --- a/lib/mongoid/persistable/unsettable.rb +++ b/lib/mongoid/persistable/unsettable.rb @@ -16,7 +16,7 @@ module Unsettable # @param [ [ String | Symbol | Array]... ] *fields # The names of the field(s) to unset. # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. def unset(*fields) prepare_atomic_operation do |ops| fields.flatten.each do |field| diff --git a/lib/mongoid/persistable/updatable.rb b/lib/mongoid/persistable/updatable.rb index c1537c648..38fb4d4fe 100644 --- a/lib/mongoid/persistable/updatable.rb +++ b/lib/mongoid/persistable/updatable.rb @@ -167,7 +167,7 @@ def update_document(options = {}) # well. Note that timeless is cleared in the before_update callback. # # @param [ Hash ] options The options. - # @param [ Array ] children The children that the :update + # @param [ Array ] children The children that the :update # callbacks will be executed on. # # @option options [ true | false ] :touch Whether or not the updated_at diff --git a/lib/mongoid/reloadable.rb b/lib/mongoid/reloadable.rb index 45f5f43b0..ab4a1f52d 100644 --- a/lib/mongoid/reloadable.rb +++ b/lib/mongoid/reloadable.rb @@ -14,7 +14,7 @@ module Reloadable # # @raise [ Errors::DocumentNotFound ] If the document was deleted. # - # @return [ Document ] The document, reloaded. + # @return [ Mongoid::Document ] The document, reloaded. def reload if @atomic_selector # Clear atomic_selector cache for sharded clusters. MONGOID-5076 diff --git a/lib/mongoid/scopable.rb b/lib/mongoid/scopable.rb index fe38e461c..10f1a7e1e 100644 --- a/lib/mongoid/scopable.rb +++ b/lib/mongoid/scopable.rb @@ -74,7 +74,7 @@ def scopes # default_scope ->{ where(active: true) } # end # - # @param [ Proc | Criteria ] value The default scope. + # @param [ Proc | Mongoid::Criteria ] value The default scope. # # @raise [ Errors::InvalidScope ] If the scope is not a proc or criteria. # @@ -102,7 +102,7 @@ def default_scopable? # @example Get a queryable. # Model.queryable # - # @return [ Criteria ] The queryable. + # @return [ Mongoid::Criteria ] The queryable. def queryable crit = Threaded.current_scope(self) || Criteria.new(self) crit.embedded = true if (crit.klass.embedded? && !crit.klass.cyclic?) @@ -153,7 +153,7 @@ def scope(name, value, &block) # limit. # @option options [ Array ] :sort Optional sorting options. # - # @return [ Criteria ] A scoped criteria. + # @return [ Mongoid::Criteria ] A scoped criteria. def scoped(options = nil) queryable.scoped(options) end @@ -171,7 +171,7 @@ def scoped(options = nil) # @note This will force the default scope, as well as any scope applied # using ``.with_scope``, to be removed. # - # @return [ Criteria | Object ] The unscoped criteria or result of the + # @return [ Mongoid::Criteria | Object ] The unscoped criteria or result of the # block. def unscoped if block_given? @@ -190,7 +190,7 @@ def unscoped # @example Get a criteria with the default scope. # Model.with_default_scope # - # @return [ Criteria ] The criteria. + # @return [ Mongoid::Criteria ] The criteria. def with_default_scope queryable.with_default_scope end @@ -202,9 +202,9 @@ def with_default_scope # @example Yield to the criteria. # Person.with_scope(criteria) # - # @param [ Criteria ] criteria The criteria to apply. + # @param [ Mongoid::Criteria ] criteria The criteria to apply. # - # @return [ Criteria ] The yielded criteria. + # @return [ Mongoid::Criteria ] The yielded criteria. def with_scope(criteria) previous = Threaded.current_scope(self) Threaded.set_current_scope(criteria, self) @@ -310,7 +310,7 @@ def define_scope_method(name) # @example Process the default scope. # Model.process_default_scope(value) # - # @param [ Criteria | Proc ] value The default scope value. + # @param [ Mongoid::Criteria | Proc ] value The default scope value. def process_default_scope(value) if existing = default_scoping ->{ existing.call.merge(value.to_proc.call) } diff --git a/lib/mongoid/threaded.rb b/lib/mongoid/threaded.rb index 19211607e..693f2c052 100644 --- a/lib/mongoid/threaded.rb +++ b/lib/mongoid/threaded.rb @@ -109,7 +109,7 @@ def stack(name) # @example Begin autosave. # Threaded.begin_autosave(doc) # - # @param [ Document ] document The document to autosave. + # @param [ Mongoid::Document ] document The document to autosave. def begin_autosave(document) autosaves_for(document.class).push(document._id) end @@ -119,7 +119,7 @@ def begin_autosave(document) # @example Begin validation. # Threaded.begin_validate(doc) # - # @param [ Document ] document The document to validate. + # @param [ Mongoid::Document ] document The document to validate. def begin_validate(document) validations_for(document.class).push(document._id) end @@ -129,7 +129,7 @@ def begin_validate(document) # @example Exit autosave. # Threaded.exit_autosave(doc) # - # @param [ Document ] document The document to autosave. + # @param [ Mongoid::Document ] document The document to autosave. def exit_autosave(document) autosaves_for(document.class).delete_one(document._id) end @@ -139,7 +139,7 @@ def exit_autosave(document) # @example Exit validation. # Threaded.exit_validate(doc) # - # @param [ Document ] document The document to validate. + # @param [ Mongoid::Document ] document The document to validate. def exit_validate(document) validations_for(document.class).delete_one(document._id) end @@ -198,7 +198,7 @@ def client_override=(name) # # @param [ Klass ] klass The class type of the scope. # - # @return [ Criteria ] The scope. + # @return [ Mongoid::Criteria ] The scope. def current_scope(klass = nil) if klass && Thread.current[CURRENT_SCOPE_KEY].respond_to?(:keys) Thread.current[CURRENT_SCOPE_KEY][ @@ -214,9 +214,9 @@ def current_scope(klass = nil) # @example Set the scope. # Threaded.current_scope = scope # - # @param [ Criteria ] scope The current scope. + # @param [ Mongoid::Criteria ] scope The current scope. # - # @return [ Criteria ] The scope. + # @return [ Mongoid::Criteria ] The scope. def current_scope=(scope) Thread.current[CURRENT_SCOPE_KEY] = scope end @@ -226,10 +226,10 @@ def current_scope=(scope) # @example Set the scope. # Threaded.current_scope(scope, klass) # - # @param [ Criteria ] scope The current scope. + # @param [ Mongoid::Criteria ] scope The current scope. # @param [ Class ] klass The current model class. # - # @return [ Criteria ] The scope. + # @return [ Mongoid::Criteria ] The scope. def set_current_scope(scope, klass) if scope.nil? if Thread.current[CURRENT_SCOPE_KEY] @@ -259,7 +259,7 @@ def without_default_scope?(klass) # @example Is the document autosaved? # Threaded.autosaved?(doc) # - # @param [ Document ] document The document to check. + # @param [ Mongoid::Document ] document The document to check. # # @return [ true | false ] If the document is autosaved. def autosaved?(document) @@ -271,7 +271,7 @@ def autosaved?(document) # @example Is the document validated? # Threaded.validated?(doc) # - # @param [ Document ] document The document to check. + # @param [ Mongoid::Document ] document The document to check. # # @return [ true | false ] If the document is validated. def validated?(document) diff --git a/lib/mongoid/timestamps/timeless.rb b/lib/mongoid/timestamps/timeless.rb index 22549dd8c..7dae8effe 100644 --- a/lib/mongoid/timestamps/timeless.rb +++ b/lib/mongoid/timestamps/timeless.rb @@ -28,7 +28,7 @@ def clear_timeless_option # @example Save a document but don't timestamp. # person.timeless.save # - # @return [ Document ] The document this was called on. + # @return [ Mongoid::Document ] The document this was called on. def timeless self.class.timeless self diff --git a/lib/mongoid/traversable.rb b/lib/mongoid/traversable.rb index ff4f4373a..0ef831fb5 100644 --- a/lib/mongoid/traversable.rb +++ b/lib/mongoid/traversable.rb @@ -141,7 +141,7 @@ def self.get_discriminator_mapping(value) # Get all child +Documents+ to this +Document+ # - # @return [ Array ] All child documents in the hierarchy. + # @return [ Array ] All child documents in the hierarchy. # # @api private def _children @@ -155,7 +155,7 @@ def _children # always be preferred, since they are optimized calls... This operation # can get expensive in domains with large hierarchies. # - # @return [ Array ] All descendant documents in the hierarchy. + # @return [ Array ] All descendant documents in the hierarchy. # # @api private def _descendants @@ -164,7 +164,7 @@ def _descendants # Collect all the children of this document. # - # @return [ Array ] The children. + # @return [ Array ] The children. # # @api private def collect_children @@ -182,7 +182,7 @@ def collect_children # Collect all the descendants of this document. # - # @return [ Array ] The descendants. + # @return [ Array ] The descendants. # # @api private def collect_descendants @@ -215,7 +215,7 @@ def collect_descendants # Marks all descendants as being persisted. # - # @return [ Array ] The flagged descendants. + # @return [ Array ] The flagged descendants. def flag_descendants_persisted _descendants.each do |child| child.new_record = false @@ -238,9 +238,9 @@ def hereditary? # @example Set the parent document. # document.parentize(parent) # - # @param [ Document ] document The parent document. + # @param [ Mongoid::Document ] document The parent document. # - # @return [ Document ] The parent document. + # @return [ Mongoid::Document ] The parent document. def parentize(document) self._parent = document end @@ -253,7 +253,7 @@ def parentize(document) # @example Remove the child. # document.remove_child(child) # - # @param [ Document ] child The child (embedded) document to remove. + # @param [ Mongoid::Document ] child The child (embedded) document to remove. def remove_child(child) name = child.association_name if child.embedded_one? @@ -268,7 +268,7 @@ def remove_child(child) # After descendants are persisted we can call this to move all their # changes and flag them as persisted in one call. # - # @return [ Array ] The descendants. + # @return [ Array ] The descendants. def reset_persisted_descendants _descendants.each do |child| child.move_changes @@ -295,7 +295,7 @@ def _reset_memoized_descendants! # @example Get the root document in the hierarchy. # document._root # - # @return [ Document ] The root document in the hierarchy. + # @return [ Mongoid::Document ] The root document in the hierarchy. def _root object = self while (object._parent) do object = object._parent; end diff --git a/lib/mongoid/validatable/associated.rb b/lib/mongoid/validatable/associated.rb index d82936879..1aba1be99 100644 --- a/lib/mongoid/validatable/associated.rb +++ b/lib/mongoid/validatable/associated.rb @@ -24,7 +24,7 @@ class AssociatedValidator < ActiveModel::EachValidator # @example Validate the association. # validator.validate_each(document, :name, name) # - # @param [ Document ] document The document to validate. + # @param [ Mongoid::Document ] document The document to validate. # @param [ Symbol ] attribute The association to validate. # @param [ Object ] value The value of the association. def validate_each(document, attribute, value) diff --git a/lib/mongoid/validatable/localizable.rb b/lib/mongoid/validatable/localizable.rb index 415f5d145..70b3f7ab0 100644 --- a/lib/mongoid/validatable/localizable.rb +++ b/lib/mongoid/validatable/localizable.rb @@ -11,7 +11,7 @@ module Localizable # @example Validate localized fields. # validator.validate_each(model, :name, "value") # - # @param [ Document ] document The document. + # @param [ Mongoid::Document ] document The document. # @param [ Symbol | String ] attribute The attribute to validate. # @param [ Object ] value The attribute value. def validate_each(document, attribute, value) diff --git a/lib/mongoid/validatable/presence.rb b/lib/mongoid/validatable/presence.rb index a4e097532..d2bd08848 100644 --- a/lib/mongoid/validatable/presence.rb +++ b/lib/mongoid/validatable/presence.rb @@ -21,7 +21,7 @@ class PresenceValidator < ActiveModel::EachValidator # @example Validate the document. # validator.validate_each(doc, :title, "") # - # @param [ Document ] document The document to validate. + # @param [ Mongoid::Document ] document The document to validate. # @param [ Symbol ] attribute The attribute name. # @param [ Object ] value The current value of the field. def validate_each(document, attribute, value) @@ -52,7 +52,7 @@ def validate_each(document, attribute, value) # @example Check is the association or fk is blank. # validator.relation_or_fk_missing(doc, :name, "") # - # @param [ Document ] doc The document. + # @param [ Mongoid::Document ] doc The document. # @param [ Symbol ] attr The attribute. # @param [ Object ] value The value. # diff --git a/lib/mongoid/validatable/queryable.rb b/lib/mongoid/validatable/queryable.rb index 9f9b3247f..9c6018507 100644 --- a/lib/mongoid/validatable/queryable.rb +++ b/lib/mongoid/validatable/queryable.rb @@ -20,7 +20,7 @@ module Queryable # #... # end # - # @param [ Document ] document The document being validated. + # @param [ Mongoid::Document ] document The document being validated. # # @return [ Object ] The result of the yield. def with_query(document) diff --git a/lib/mongoid/validatable/uniqueness.rb b/lib/mongoid/validatable/uniqueness.rb index 60adf7609..660cfe0f0 100644 --- a/lib/mongoid/validatable/uniqueness.rb +++ b/lib/mongoid/validatable/uniqueness.rb @@ -32,7 +32,7 @@ class UniquenessValidator < ActiveModel::EachValidator # @example Validate the document. # validate_each(person, :title, "Sir") # - # @param [ Document ] document The document to validate. + # @param [ Mongoid::Document ] document The document to validate. # @param [ Symbol ] attribute The field to validate on. # @param [ Object ] value The value of the field. # @@ -58,7 +58,7 @@ def validate_each(document, attribute, value) # @example Add the error. # validator.add_error(doc, :name, "test") # - # @param [ Document ] document The document to validate. + # @param [ Mongoid::Document ] document The document to validate. # @param [ Symbol ] attribute The name of the attribute. # @param [ Object ] value The value of the object. def add_error(document, attribute, value) @@ -87,11 +87,11 @@ def case_sensitive? # validator.create_criteria(User, user, :name, "syd") # # @param [ Class | Proxy ] base The base to execute the criteria from. - # @param [ Document ] document The document to validate. + # @param [ Mongoid::Document ] document The document to validate. # @param [ Symbol ] attribute The name of the attribute. # @param [ Object ] value The value of the object. # - # @return [ Criteria ] The criteria. + # @return [ Mongoid::Criteria ] The criteria. def create_criteria(base, document, attribute, value) criteria = scope(base.unscoped, document, attribute) field = document.fields[document.database_field_name(attribute)] @@ -119,11 +119,11 @@ def create_criteria(base, document, attribute, value) # @example Get the criteria. # validator.criterion(person, :title, "Sir") # - # @param [ Document ] document The document to validate. + # @param [ Mongoid::Document ] document The document to validate. # @param [ Symbol ] attribute The name of the attribute. # @param [ Object ] value The value of the object. # - # @return [ Criteria ] The uniqueness criteria. + # @return [ Mongoid::Criteria ] The uniqueness criteria. def criterion(document, attribute, value) field = document.database_field_name(attribute) @@ -161,10 +161,10 @@ def filter(value) # @example Scope the criteria. # validator.scope(criteria, document) # - # @param [ Criteria ] criteria The criteria to scope. - # @param [ Document ] document The document being validated. + # @param [ Mongoid::Criteria ] criteria The criteria to scope. + # @param [ Mongoid::Document ] document The document being validated. # - # @return [ Criteria ] The scoped criteria. + # @return [ Mongoid::Criteria ] The scoped criteria. def scope(criteria, document, _attribute) Array.wrap(options[:scope]).each do |item| name = document.database_field_name(item) @@ -180,7 +180,7 @@ def scope(criteria, document, _attribute) # @example Should the validation be skipped? # validator.skip_validation?(doc) # - # @param [ Document ] document The embedded document. + # @param [ Mongoid::Document ] document The embedded document. # # @return [ true | false ] If the validation should be skipped. def skip_validation?(document) @@ -194,7 +194,7 @@ def skip_validation?(document) # @example Has scope reference changed? # validator.scope_value_changed?(doc) # - # @param [ Document ] document The embedded document. + # @param [ Mongoid::Document ] document The embedded document. # # @return [ true | false ] If the scope reference has changed. def scope_value_changed?(document) @@ -213,7 +213,7 @@ def scope_value_changed?(document) # @example Get the name and key to validate. # validator.to_validate(doc, :parent, Parent.new) # - # @param [ Document ] document The doc getting validated. + # @param [ Mongoid::Document ] document The doc getting validated. # @param [ Symbol ] attribute The attribute getting validated. # @param [ Object ] value The value of the attribute. # @@ -234,7 +234,7 @@ def to_validate(document, attribute, value) # @example Validate the embedded document. # validator.validate_embedded(doc, :name, "test") # - # @param [ Document ] document The document. + # @param [ Mongoid::Document ] document The document. # @param [ Symbol ] attribute The attribute name. # @param [ Object ] value The value. def validate_embedded(document, attribute, value) @@ -253,7 +253,7 @@ def validate_embedded(document, attribute, value) # @example Validate the root document. # validator.validate_root(doc, :name, "test") # - # @param [ Document ] document The document. + # @param [ Mongoid::Document ] document The document. # @param [ Symbol ] attribute The attribute name. # @param [ Object ] value The value. def validate_root(document, attribute, value) @@ -275,7 +275,7 @@ def validate_root(document, attribute, value) # @example Is validation needed? # validator.validation_required?(doc, :field) # - # @param [ Document ] document The document getting validated. + # @param [ Mongoid::Document ] document The document getting validated. # @param [ Symbol ] attribute The attribute to validate. # # @return [ true | false ] If we need to validate. @@ -292,7 +292,7 @@ def validation_required?(document, attribute) # @example Is the attribute localized? # validator.localized?(doc, :field) # - # @param [ Document ] document The document getting validated. + # @param [ Mongoid::Document ] document The document getting validated. # @param [ Symbol ] attribute The attribute to validate. # # @return [ true | false ] If the attribute is localized.