diff --git a/docs/contributing/code-documentation.txt b/docs/contributing/code-documentation.txt index 9713ce278a..01d087e29f 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 da7d4328d0..8eb8e84f8c 100644 --- a/lib/mongoid/association/accessors.rb +++ b/lib/mongoid/association/accessors.rb @@ -23,7 +23,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) @@ -34,13 +34,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) @@ -82,9 +82,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 @@ -104,7 +104,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 e1ec116a53..3b2da63a95 100644 --- a/lib/mongoid/association/bindable.rb +++ b/lib/mongoid/association/bindable.rb @@ -15,8 +15,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 @@ -47,7 +47,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) @@ -63,7 +63,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? @@ -78,7 +78,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 @@ -98,7 +98,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 @@ -116,7 +116,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? @@ -132,7 +132,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 && !typed.frozen? @@ -148,7 +148,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 && !typed.frozen? @@ -164,8 +164,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.frozen? try_method(doc, _association.inverse_setter, inverse) @@ -179,7 +179,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) @@ -216,7 +216,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/eager.rb b/lib/mongoid/association/eager.rb index 3e9ec78fda..4be7787fa9 100644 --- a/lib/mongoid/association/eager.rb +++ b/lib/mongoid/association/eager.rb @@ -13,7 +13,7 @@ class Eager # # @param [ Array ] associations # Associations to eager load - # @param [ Array ] docs Documents to preload the associations + # @param [ Array ] docs Documents to preload the associations # # @return [ Base ] The eager load preloader def initialize(associations, docs) @@ -84,7 +84,7 @@ def each_loaded_document(&block) # loader.set_on_parent("foo", docs) # # @param [ ObjectId ] id parent`s id - # @param [ Document | Array ] element to push into the parent + # @param [ Mongoid::Document | Array ] element to push into the parent def set_on_parent(id, element) grouped_docs[id].each do |d| set_relation(d, element) @@ -138,8 +138,8 @@ def group_by_key # @example Set docs into parent using the current association name. # loader.set_relation(doc, docs) # - # @param [ Document ] doc The object to set the association on - # @param [ Document | Array ] element to set into the parent + # @param [ Mongoid::Document ] doc The object to set the association on + # @param [ Mongoid::Document | Array ] element to set into the parent def set_relation(doc, element) doc.set_relation(@association.name, element) unless doc.blank? end diff --git a/lib/mongoid/association/embedded/batchable.rb b/lib/mongoid/association/embedded/batchable.rb index ef95358972..3d6ce7a373 100644 --- a/lib/mongoid/association/embedded/batchable.rb +++ b/lib/mongoid/association/embedded/batchable.rb @@ -17,7 +17,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) @@ -29,7 +29,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) @@ -54,7 +54,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 @@ -96,7 +96,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) @@ -149,7 +149,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) @@ -172,7 +172,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) @@ -234,9 +234,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| @@ -309,7 +309,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) @@ -335,7 +335,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. @@ -362,7 +362,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) @@ -380,10 +380,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 ea55921ab7..f0154a3a7e 100644 --- a/lib/mongoid/association/embedded/embedded_in/binding.rb +++ b/lib/mongoid/association/embedded/embedded_in/binding.rb @@ -58,7 +58,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 e82dfae3ee..2cce5358d3 100644 --- a/lib/mongoid/association/embedded/embedded_in/buildable.rb +++ b/lib/mongoid/association/embedded/embedded_in/buildable.rb @@ -16,14 +16,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 1bea6b8b9d..e5278652cf 100644 --- a/lib/mongoid/association/embedded/embedded_in/proxy.rb +++ b/lib/mongoid/association/embedded/embedded_in/proxy.rb @@ -16,8 +16,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. @@ -34,9 +34,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 @@ -67,7 +67,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) _base._association ||= _association.inverse_association(document) end @@ -112,7 +112,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 d38280e4fe..8481bf2ba5 100644 --- a/lib/mongoid/association/embedded/embeds_many.rb +++ b/lib/mongoid/association/embedded/embeds_many.rb @@ -122,7 +122,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. @@ -132,8 +132,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 e2d7f41a77..765f628ac9 100644 --- a/lib/mongoid/association/embedded/embeds_many/binding.rb +++ b/lib/mongoid/association/embedded/embeds_many/binding.rb @@ -16,7 +16,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 @@ -30,7 +30,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 try_method(doc, _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 0059ee9eb5..58513849fa 100644 --- a/lib/mongoid/association/embedded/embeds_many/buildable.rb +++ b/lib/mongoid/association/embedded/embeds_many/buildable.rb @@ -18,15 +18,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 f7e5d810a1..c6f8378138 100644 --- a/lib/mongoid/association/embedded/embeds_many/proxy.rb +++ b/lib/mongoid/association/embedded/embeds_many/proxy.rb @@ -59,8 +59,8 @@ def foreign_key_suffix # @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. @@ -85,7 +85,7 @@ def initialize(base, target, association) # @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 unless docs.any? @@ -117,9 +117,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 @@ -134,7 +134,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) Factory.execute_build(type || _association.klass, attributes, execute_callbacks: false).tap do |doc| append(doc) @@ -202,9 +202,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 _target.delete_one(document).tap do |doc| @@ -230,7 +230,7 @@ def delete(document) # Removes a single document from the collection *in memory only*. # It will *not* persist the change. # - # @param [ Document ] document The document to delete. + # @param [ Mongoid::Document ] document The document to delete. # # @api private def _remove(document) @@ -336,7 +336,7 @@ def exists?(id_or_conditions = :none) # @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 @@ -346,7 +346,7 @@ def find(*args, &block) # @example Get the in memory documents. # relation.in_memory # - # @return [ Array ] The documents in memory. + # @return [ Array ] The documents in memory. alias in_memory _target # Pop documents off the association. This can be a single document or @@ -361,7 +361,7 @@ def find(*args, &block) # @param [ Integer ] count The number of documents to pop, or 1 if not # provided. # - # @return [ Document | Array | nil ] The popped document(s). + # @return [ Mongoid::Document | Array | nil ] The popped document(s). def pop(count = nil) return [] if count&.zero? @@ -381,7 +381,7 @@ def pop(count = nil) # @param [ Integer ] count The number of documents to shift, or 1 if not # provided. # - # @return [ Document | Array | nil ] The shifted document(s). + # @return [ Mongoid::Document | Array | nil ] The shifted document(s). def shift(count = nil) return [] if count&.zero? @@ -395,7 +395,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) @@ -410,7 +410,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 @@ -432,7 +432,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 _target.push(*scope([ document ])) unless object_already_related?(document) @@ -456,7 +456,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 @@ -467,7 +467,7 @@ def criteria # @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) @@ -482,7 +482,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. # # TODO: make sure we are consistingly using respond_to_missing # anywhere we define method_missing. @@ -524,9 +524,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) return docs unless _association.order || _association.klass.default_scoping? diff --git a/lib/mongoid/association/embedded/embeds_one/buildable.rb b/lib/mongoid/association/embedded/embeds_one/buildable.rb index 1e96ebc566..323767603a 100644 --- a/lib/mongoid/association/embedded/embeds_one/buildable.rb +++ b/lib/mongoid/association/embedded/embeds_one/buildable.rb @@ -17,14 +17,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 b81a200383..203eef943d 100644 --- a/lib/mongoid/association/embedded/embeds_one/proxy.rb +++ b/lib/mongoid/association/embedded/embeds_one/proxy.rb @@ -27,8 +27,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) super do @@ -47,9 +47,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) return self if replacement == self @@ -92,7 +92,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 @@ -207,7 +207,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 82f53a8e26..c1dcef4d1f 100644 --- a/lib/mongoid/association/many.rb +++ b/lib/mongoid/association/many.rb @@ -32,7 +32,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) } @@ -55,7 +55,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) } @@ -80,7 +80,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 @@ -96,7 +96,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 @@ -110,7 +110,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 @@ -144,7 +144,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 @@ -173,7 +173,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 @@ -193,7 +193,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 a078a5c647..d1c08dbc42 100644 --- a/lib/mongoid/association/nested/many.rb +++ b/lib/mongoid/association/nested/many.rb @@ -20,7 +20,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. @@ -97,7 +97,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) @@ -117,9 +117,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? @@ -136,8 +136,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) @@ -151,7 +151,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) delete_id(attrs) @@ -169,7 +169,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 81d6b292b6..ec9d259775 100644 --- a/lib/mongoid/association/nested/nested_buildable.rb +++ b/lib/mongoid/association/nested/nested_buildable.rb @@ -27,7 +27,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 5fbc9397da..70c9824c44 100644 --- a/lib/mongoid/association/nested/one.rb +++ b/lib/mongoid/association/nested/one.rb @@ -22,9 +22,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 6e89f3c64e..abd696a610 100644 --- a/lib/mongoid/association/one.rb +++ b/lib/mongoid/association/one.rb @@ -23,7 +23,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 3c3ede1463..30cb391e74 100644 --- a/lib/mongoid/association/options.rb +++ b/lib/mongoid/association/options.rb @@ -23,7 +23,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 6bbef1172d..6508131c0f 100644 --- a/lib/mongoid/association/proxy.rb +++ b/lib/mongoid/association/proxy.rb @@ -54,8 +54,8 @@ class Proxy # Sets the target and the association metadata properties. # - # @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 initialize(base, target, association) @_base, @_target, @_association = base, target, association @@ -116,7 +116,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 @@ -158,7 +158,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) @@ -199,10 +199,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 244c306e68..7de33ef77c 100644 --- a/lib/mongoid/association/referenced/belongs_to.rb +++ b/lib/mongoid/association/referenced/belongs_to.rb @@ -125,7 +125,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 9c2a8402f4..470cb3289f 100644 --- a/lib/mongoid/association/referenced/belongs_to/binding.rb +++ b/lib/mongoid/association/referenced/belongs_to/binding.rb @@ -68,7 +68,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 a184667471..5e73ad2988 100644 --- a/lib/mongoid/association/referenced/belongs_to/buildable.rb +++ b/lib/mongoid/association/referenced/belongs_to/buildable.rb @@ -20,7 +20,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 20428991de..2d6ec8316a 100644 --- a/lib/mongoid/association/referenced/belongs_to/proxy.rb +++ b/lib/mongoid/association/referenced/belongs_to/proxy.rb @@ -19,8 +19,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) @@ -47,7 +47,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) @@ -78,9 +78,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) @@ -103,7 +103,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 44572cb954..51a3f02ff1 100644 --- a/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +++ b/lib/mongoid/association/referenced/has_and_belongs_to_many.rb @@ -130,7 +130,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) @@ -160,7 +160,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 c67f421549..f59735b1f5 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 @@ -16,7 +16,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 = try_method(doc, _association.inverse_foreign_key) unless doc.frozen? 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 7b6aaeef5a..941a629336 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 @@ -20,7 +20,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 8046f38fe4..7a4780c99b 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 @@ -19,7 +19,7 @@ module ClassMethods # @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. def eager_loader(association, docs) Eager.new(association, docs) end @@ -50,9 +50,9 @@ def embedded? # @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. # # rubocop:disable Metrics/AbcSize def <<(*args) @@ -99,9 +99,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 { |doc| append_document(doc, ids, docs, inserts) } @@ -119,7 +119,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) @@ -140,9 +140,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? @@ -164,7 +164,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 { |doc| execute_callback :before_remove, doc } cleanup_inverse_for(replacement) unless _association.forced_nil_inverse? @@ -183,7 +183,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) @@ -203,7 +203,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 @@ -239,7 +239,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) @@ -266,7 +266,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) @@ -280,7 +280,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 @@ -292,7 +292,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. @@ -304,7 +304,7 @@ def unsynced(doc, key) # Does the cleanup for the inverse of the association when # replacing the relation with another list of documents. # - # @param [ Array | nil ] replacement the list of documents + # @param [ Array | nil ] replacement the list of documents # that will replace the current list. def cleanup_inverse_for(replacement) if replacement @@ -332,7 +332,7 @@ def inverse_primary_key # saved, the processing completes, and *then* the exception is # re-raised. # - # @return [ Array ] the replacement documents + # @return [ Array ] the replacement documents def clear_target_for_nullify after_remove_error = nil many_to_many = _target.clear do |doc| diff --git a/lib/mongoid/association/referenced/has_many.rb b/lib/mongoid/association/referenced/has_many.rb index 40d1125107..dec0c0c74a 100644 --- a/lib/mongoid/association/referenced/has_many.rb +++ b/lib/mongoid/association/referenced/has_many.rb @@ -149,7 +149,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) @@ -171,7 +171,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 5d19a471c9..db6b3eac4c 100644 --- a/lib/mongoid/association/referenced/has_many/buildable.rb +++ b/lib/mongoid/association/referenced/has_many/buildable.rb @@ -20,7 +20,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 b388e404be..e0a7e97d69 100644 --- a/lib/mongoid/association/referenced/has_many/enumerable.rb +++ b/lib/mongoid/association/referenced/has_many/enumerable.rb @@ -54,9 +54,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 @@ -75,7 +75,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) } @@ -90,7 +90,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 @@ -100,9 +100,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 @@ -125,7 +125,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) @@ -242,7 +242,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)] || @@ -258,7 +258,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 @@ -278,7 +278,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) @@ -305,7 +305,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| @@ -327,7 +327,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) || @@ -392,7 +392,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 @@ -460,7 +460,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 ef0bd2bd08..4a5c2892dc 100644 --- a/lib/mongoid/association/referenced/has_many/proxy.rb +++ b/lib/mongoid/association/referenced/has_many/proxy.rb @@ -45,8 +45,8 @@ def embedded? # @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) @@ -67,9 +67,9 @@ def initialize(base, target, association) # @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 @@ -89,9 +89,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| @@ -114,7 +114,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) Factory.execute_build(type || klass, attributes, execute_callbacks: false).tap do |doc| append(doc) @@ -134,9 +134,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 result = _target.delete(document) do |doc| @@ -196,7 +196,7 @@ def destroy_all(conditions = nil) # post.save # end # - # @return [ Array ] The loaded docs. + # @return [ Array ] The loaded docs. def each(&block) if block _target.each(&block) @@ -261,7 +261,7 @@ def exists?(id_or_conditions = :none) # @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) } @@ -321,7 +321,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) @@ -345,7 +345,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 @@ -358,7 +358,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) @@ -373,7 +373,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) @@ -387,7 +387,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. @@ -424,7 +424,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 @@ -435,7 +435,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) @@ -460,7 +460,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. # # TODO: make sure we are consistingly using respond_to_missing # anywhere we define method_missing. @@ -483,7 +483,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) return if docs.empty? @@ -554,7 +554,7 @@ def remove_not_in(ids) # If the association is destructive, the matching documents will # be removed. Otherwise, their foreign keys will be set to nil. # - # @param [ Criteria ] removed The criteria for the documents to + # @param [ Mongoid::Criteria ] removed The criteria for the documents to # remove. def update_or_delete_all(removed) if _association.destructive? @@ -572,8 +572,8 @@ def update_or_delete_all(removed) # @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 2e53ccb51f..06d8fdcbc2 100644 --- a/lib/mongoid/association/referenced/has_one.rb +++ b/lib/mongoid/association/referenced/has_one.rb @@ -110,7 +110,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) @@ -127,7 +127,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 9bdfd437eb..9f1a86435c 100644 --- a/lib/mongoid/association/referenced/has_one/buildable.rb +++ b/lib/mongoid/association/referenced/has_one/buildable.rb @@ -18,7 +18,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 5cd775f3d3..a2e6e24684 100644 --- a/lib/mongoid/association/referenced/has_one/proxy.rb +++ b/lib/mongoid/association/referenced/has_one/proxy.rb @@ -37,8 +37,8 @@ def embedded? # @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) super do @@ -67,7 +67,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 fc485c4d94..54a68215ed 100644 --- a/lib/mongoid/association/relatable.rb +++ b/lib/mongoid/association/relatable.rb @@ -87,7 +87,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 @@ -248,11 +248,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 - # association. + # @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 7dc970c537..dfadc9badd 100644 --- a/lib/mongoid/atomic.rb +++ b/lib/mongoid/atomic.rb @@ -30,7 +30,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 @@ -43,9 +43,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 @@ -329,7 +329,7 @@ def reset_atomic_updates! # 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 2bd7ae7e21..3c562b8999 100644 --- a/lib/mongoid/atomic/paths/embedded/many.rb +++ b/lib/mongoid/atomic/paths/embedded/many.rb @@ -16,7 +16,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" @@ -45,7 +45,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 b470668cbe..9eb7c48e2a 100644 --- a/lib/mongoid/atomic/paths/embedded/one.rb +++ b/lib/mongoid/atomic/paths/embedded/one.rb @@ -16,7 +16,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 04ac3c0fc5..25c17b223d 100644 --- a/lib/mongoid/atomic/paths/root.rb +++ b/lib/mongoid/atomic/paths/root.rb @@ -16,7 +16,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 fe0024be7e..0f57d84efd 100644 --- a/lib/mongoid/contextual.rb +++ b/lib/mongoid/contextual.rb @@ -45,7 +45,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 7e328fae92..addce36a3a 100644 --- a/lib/mongoid/contextual/aggregable/memory.rb +++ b/lib/mongoid/contextual/aggregable/memory.rb @@ -51,7 +51,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? @@ -73,7 +73,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 1b050281f5..d711cdb39f 100644 --- a/lib/mongoid/contextual/aggregable/mongo.rb +++ b/lib/mongoid/contextual/aggregable/mongo.rb @@ -61,7 +61,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"] @@ -81,7 +81,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 f0bda793c1..e46bdd3a66 100644 --- a/lib/mongoid/contextual/geo_near.rb +++ b/lib/mongoid/contextual/geo_near.rb @@ -64,7 +64,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 9cee7882d3..6052d38fd8 100644 --- a/lib/mongoid/contextual/map_reduce.rb +++ b/lib/mongoid/contextual/map_reduce.rb @@ -71,7 +71,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 6f9d2e8083..0e52d85480 100644 --- a/lib/mongoid/contextual/memory.rb +++ b/lib/mongoid/contextual/memory.rb @@ -139,7 +139,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)) @@ -156,7 +156,7 @@ def first(limit = nil) # @example Get the first document. # context.first! # - # @return [ Document ] The first document. + # @return [ Mongoid::Document ] The first document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -169,7 +169,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| @@ -202,7 +202,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)) @@ -217,7 +217,7 @@ def last(limit = nil) # @example Get the last document. # context.last! # - # @return [ Document ] The last document. + # @return [ Mongoid::Document ] The last document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -300,7 +300,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)) @@ -315,7 +315,7 @@ def take(limit = nil) # @example Take a document. # context.take # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -378,7 +378,7 @@ def update_all(attributes = nil) # @example Get the second document. # context.second # - # @return [ Document ] The second document. + # @return [ Mongoid::Document ] The second document. def second eager_load([documents.second]).first end @@ -389,7 +389,7 @@ def second # @example Get the second document. # context.second! # - # @return [ Document ] The second document. + # @return [ Mongoid::Document ] The second document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -402,7 +402,7 @@ def second! # @example Get the third document. # context.third # - # @return [ Document ] The third document. + # @return [ Mongoid::Document ] The third document. def third eager_load([documents.third]).first end @@ -413,7 +413,7 @@ def third # @example Get the third document. # context.third! # - # @return [ Document ] The third document. + # @return [ Mongoid::Document ] The third document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -426,7 +426,7 @@ def third! # @example Get the fourth document. # context.fourth # - # @return [ Document ] The fourth document. + # @return [ Mongoid::Document ] The fourth document. def fourth eager_load([documents.fourth]).first end @@ -437,7 +437,7 @@ def fourth # @example Get the fourth document. # context.fourth! # - # @return [ Document ] The fourth document. + # @return [ Mongoid::Document ] The fourth document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -450,7 +450,7 @@ def fourth! # @example Get the fifth document. # context.fifth # - # @return [ Document ] The fifth document. + # @return [ Mongoid::Document ] The fifth document. def fifth eager_load([documents.fifth]).first end @@ -461,7 +461,7 @@ def fifth # @example Get the fifth document. # context.fifth! # - # @return [ Document ] The fifth document. + # @return [ Mongoid::Document ] The fifth document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -474,7 +474,7 @@ def fifth! # @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. def second_to_last eager_load([documents.second_to_last]).first end @@ -485,7 +485,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. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -498,7 +498,7 @@ def second_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. def third_to_last eager_load([documents.third_to_last]).first end @@ -509,7 +509,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. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -526,7 +526,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? @@ -543,7 +543,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" => {}} @@ -668,7 +668,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 @@ -759,7 +759,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 3fceba9dfc..b1c9448438 100644 --- a/lib/mongoid/contextual/mongo.rb +++ b/lib/mongoid/contextual/mongo.rb @@ -213,7 +213,7 @@ def exists?(id_or_conditions = :none) # 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) @@ -233,7 +233,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) @@ -246,7 +246,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) @@ -292,7 +292,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 @@ -395,7 +395,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 @@ -412,7 +412,7 @@ def take(limit = nil) # @example Take a document # context.take! # - # @return [ Document ] The document. + # @return [ Mongoid::Document ] The document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents to take. @@ -572,7 +572,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) @@ -594,7 +594,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. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -615,7 +615,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) @@ -636,7 +636,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. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -649,7 +649,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 @@ -660,7 +660,7 @@ def second # @example Get the second document. # context.second! # - # @return [ Document ] The second document. + # @return [ Mongoid::Document ] The second document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -673,7 +673,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 @@ -684,7 +684,7 @@ def third # @example Get the third document. # context.third! # - # @return [ Document ] The third document. + # @return [ Mongoid::Document ] The third document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -697,7 +697,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 @@ -708,7 +708,7 @@ def fourth # @example Get the fourth document. # context.fourth! # - # @return [ Document ] The fourth document. + # @return [ Mongoid::Document ] The fourth document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -721,7 +721,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 @@ -732,7 +732,7 @@ def fifth # @example Get the fifth document. # context.fifth! # - # @return [ Document ] The fifth document. + # @return [ Mongoid::Document ] The fifth document. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -746,7 +746,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) @@ -758,7 +758,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. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -772,7 +772,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) @@ -784,7 +784,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. # # @raise [ Mongoid::Errors::DocumentNotFound ] raises when there are no # documents available. @@ -875,7 +875,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 @@ -904,7 +904,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) @@ -1036,7 +1036,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 9f1fbce8c2..6453658789 100644 --- a/lib/mongoid/contextual/none.rb +++ b/lib/mongoid/contextual/none.rb @@ -116,7 +116,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 34834b8ffd..39a616f3d9 100644 --- a/lib/mongoid/copyable.rb +++ b/lib/mongoid/copyable.rb @@ -20,7 +20,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 @@ -40,7 +40,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 ca024cace9..309e8f7517 100644 --- a/lib/mongoid/criteria.rb +++ b/lib/mongoid/criteria.rb @@ -51,7 +51,7 @@ class << self # # @param [ Hash ] hash The hash to convert. # - # @return [ Criteria ] The criteria. + # @return [ Mongoid::Criteria ] The criteria. def from_hash(hash) criteria = Criteria.new(hash.delete(:klass) || hash.delete('klass')) hash.each_pair do |method, args| @@ -114,7 +114,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+ @@ -146,7 +146,7 @@ def as_json(options = nil) # @example Get the documents. # criteria.documents # - # @return [ Array ] The documents. + # @return [ Array ] The documents. def documents @documents ||= [] end @@ -155,9 +155,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 @@ -191,7 +191,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) @@ -219,7 +219,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 @@ -254,9 +254,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) @@ -268,9 +268,9 @@ def merge(other) # @example Merge another criteria into this criteria. # criteria.merge(Person.where(name: "bob")) # - # @param [ Criteria | Hash ] other The criteria to merge in. + # @param [ Mongoid::Criteria | Hash ] other The criteria to merge in. # - # @return [ Criteria ] The merged criteria. + # @return [ Mongoid::Criteria ] The merged criteria. def merge!(other) other = self.class.from_hash(other) if other.is_a?(Hash) selector.merge!(other.selector) @@ -287,7 +287,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 @@ -309,7 +309,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? @@ -329,7 +329,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) @@ -343,7 +343,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) @@ -369,7 +369,8 @@ def respond_to?(name, include_private = false) # @example Convert to a criteria. # criteria.to_criteria # - # @return [ Criteria ] self. + # @return [ Mongoid::Criteria ] self. + # # @deprecated def to_criteria self @@ -395,7 +396,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 @@ -416,7 +417,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 @@ -442,7 +443,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 @@ -460,7 +461,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. # # @deprecated def for_js(javascript, scope = {}) @@ -484,7 +485,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 @@ -506,7 +507,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 527821a631..4a9b4798a7 100644 --- a/lib/mongoid/criteria/findable.rb +++ b/lib/mongoid/criteria/findable.rb @@ -19,7 +19,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) @@ -39,7 +39,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 = prepare_ids_for_find(args) raise_invalid if ids.any?(&:nil?) @@ -56,7 +56,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 @@ -74,7 +74,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) @@ -104,7 +104,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 1b6d3607b9..2522b3f186 100644 --- a/lib/mongoid/criteria/includable.rb +++ b/lib/mongoid/criteria/includable.rb @@ -25,7 +25,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 eeb6e6431c..74dd333d2d 100644 --- a/lib/mongoid/criteria/modifiable.rb +++ b/lib/mongoid/criteria/modifiable.rb @@ -22,7 +22,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 @@ -37,7 +37,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 @@ -54,7 +54,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 @@ -83,7 +83,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 @@ -99,7 +99,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 @@ -112,7 +112,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 @@ -125,7 +125,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 @@ -139,7 +139,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 @@ -152,7 +152,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 @@ -170,7 +170,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)| @@ -200,7 +200,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 @@ -215,7 +215,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 1aa7179f14..9d548c536f 100644 --- a/lib/mongoid/criteria/queryable.rb +++ b/lib/mongoid/criteria/queryable.rb @@ -80,7 +80,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 15a317fdd9..485d54f80a 100644 --- a/lib/mongoid/criteria/queryable/mergeable.rb +++ b/lib/mongoid/criteria/queryable/mergeable.rb @@ -46,7 +46,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 @@ -58,7 +58,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 @@ -152,7 +152,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. # @@ -336,7 +336,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 45a7c8d18e..74ab492766 100644 --- a/lib/mongoid/criteria/queryable/optional.rb +++ b/lib/mongoid/criteria/queryable/optional.rb @@ -334,7 +334,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 3a4373baa4..994f1c38c9 100644 --- a/lib/mongoid/criteria/queryable/selectable.rb +++ b/lib/mongoid/criteria/queryable/selectable.rb @@ -70,7 +70,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. # @@ -518,7 +518,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. @@ -547,7 +547,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. @@ -594,7 +594,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. @@ -636,7 +636,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. # @@ -666,7 +666,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 576c10361d..00d2a36720 100644 --- a/lib/mongoid/criteria/scopable.rb +++ b/lib/mongoid/criteria/scopable.rb @@ -14,7 +14,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) @@ -29,9 +29,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) @@ -53,9 +53,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) @@ -73,7 +73,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 || {}) @@ -98,7 +98,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? @@ -148,7 +148,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 b619ace2b8..43941e6a4d 100644 --- a/lib/mongoid/document.rb +++ b/lib/mongoid/document.rb @@ -45,7 +45,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 @@ -98,7 +98,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, &block) end @@ -172,7 +172,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) mongoid_document_check!(klass) @@ -230,7 +230,7 @@ def _handle_callbacks_after_instantiation(execute_callbacks) # @option options [ true | false ] :execute_callbacks Flag specifies # whether callbacks should be run. # - # @return [ Document ] A new document. + # @return [ Mongoid::Document ] A new document. # # @note A Ruby 2.x bug prevents the options hash from being keyword # arguments. Once we drop support for Ruby 2.x, we can reimplement @@ -407,7 +407,7 @@ def with_callbacks(execute_callbacks) # @param [ Integer ] selected_fields The selected fields from the # criteria. # - # @return [ Document ] A new document. + # @return [ Mongoid::Document ] A new document. def instantiate(attrs = nil, selected_fields = nil, &block) instantiate_document(attrs, selected_fields, &block) end @@ -425,7 +425,7 @@ def instantiate(attrs = nil, selected_fields = nil, &block) # @yield [ Mongoid::Document ] If a block is given, yields the newly # instantiated document to it. # - # @return [ Document ] A new document. + # @return [ Mongoid::Document ] A new document. # # @note A Ruby 2.x bug prevents the options hash from being keyword # arguments. Once we drop support for Ruby 2.x, we can reimplement @@ -459,7 +459,7 @@ def instantiate_document(attrs = nil, selected_fields = nil, options = {}, &bloc # the options hash as keyword arguments. # See https://bugs.ruby-lang.org/issues/15753 # - # @return [ Document ] A new document. + # @return [ Mongoid::Document ] A new document. # # @api private def construct_document(attrs = nil, options = {}) diff --git a/lib/mongoid/equality.rb b/lib/mongoid/equality.rb index 16bcbce486..e191b23ab5 100644 --- a/lib/mongoid/equality.rb +++ b/lib/mongoid/equality.rb @@ -14,7 +14,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) @@ -27,7 +27,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) @@ -40,7 +40,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) @@ -53,7 +53,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 a164eab4ae..4fbd8d1ede 100644 --- a/lib/mongoid/errors/delete_restriction.rb +++ b/lib/mongoid/errors/delete_restriction.rb @@ -10,7 +10,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 19aaef11af..daeed2cea1 100644 --- a/lib/mongoid/extensions/hash.rb +++ b/lib/mongoid/extensions/hash.rb @@ -100,7 +100,8 @@ 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. + # # @deprecated def to_criteria Criteria.from_hash(self) diff --git a/lib/mongoid/factory.rb b/lib/mongoid/factory.rb index bbd21785c8..f98601e07f 100644 --- a/lib/mongoid/factory.rb +++ b/lib/mongoid/factory.rb @@ -76,7 +76,7 @@ def instance(execute_callbacks: Threaded.execute_callbacks?) # @param [ true | false ] execute_callbacks Whether this method should # invoke document callbacks. # - # @return [ Document ] The instantiated document. + # @return [ Mongoid::Document ] The instantiated document. def instantiate_without_type(execute_callbacks) klass.instantiate_document(attributes, selected_fields, execute_callbacks: execute_callbacks).tap do |obj| if criteria&.association && criteria&.parent_document @@ -91,7 +91,7 @@ def instantiate_without_type(execute_callbacks) # @param [ true | false ] execute_callbacks Whether this method should # invoke document callbacks. # - # @return [ Document ] The instantiated document. + # @return [ Mongoid::Document ] The instantiated document. def instantiate_with_type(execute_callbacks) constantized_type.instantiate_document( attributes, selected_fields, @@ -150,7 +150,7 @@ def constantize(type) # @option options [ 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) end @@ -169,7 +169,7 @@ def build(klass, attributes = nil) # the options hash as keyword arguments. # See https://bugs.ruby-lang.org/issues/15753 # - # @return [ Document ] The instantiated document. + # @return [ Mongoid::Document ] The instantiated document. # # @api private def execute_build(klass, attributes = nil, options = {}) @@ -203,12 +203,12 @@ def execute_build(klass, attributes = nil, options = {}) # # @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) end @@ -217,7 +217,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. @@ -228,7 +228,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, diff --git a/lib/mongoid/fields/foreign_key.rb b/lib/mongoid/fields/foreign_key.rb index 815d5cdc99..c458ea4cd3 100644 --- a/lib/mongoid/fields/foreign_key.rb +++ b/lib/mongoid/fields/foreign_key.rb @@ -16,7 +16,7 @@ class ForeignKey < Standard # # @todo: 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. @@ -152,7 +152,7 @@ def mongoize_foreign_key(object) # @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 b6a9f67579..972f2ed3af 100644 --- a/lib/mongoid/fields/standard.rb +++ b/lib/mongoid/fields/standard.rb @@ -21,7 +21,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. @@ -37,7 +37,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) @@ -203,7 +203,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) @@ -220,7 +220,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 fccfe2b1cd..2cc0363585 100644 --- a/lib/mongoid/findable.rb +++ b/lib/mongoid/findable.rb @@ -162,7 +162,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. @@ -188,7 +188,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 @@ -208,7 +208,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 @@ -223,7 +223,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 @@ -236,7 +236,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 9b5f205f88..8e0de1fe68 100644 --- a/lib/mongoid/interceptable.rb +++ b/lib/mongoid/interceptable.rb @@ -143,7 +143,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. # @@ -165,7 +165,7 @@ def _mongoid_run_child_callbacks(kind, children: nil, &block) # is implemented. # # @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. # @@ -188,7 +188,7 @@ def _mongoid_run_child_callbacks_with_around(kind, children: nil, &block) # around callbacks. # # @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. # @@ -209,7 +209,7 @@ def _mongoid_run_child_callbacks_without_around(kind, children: nil, &block) # Execute the before callbacks of given kind for embedded documents. # # @param [ Symbol ] kind The type of callback to execute. - # @param [ Array ] children Children to execute callbacks on. + # @param [ Array ] children Children to execute callbacks on. # @param [ Array ] callback_list List of # pairs of callback sequence and environment. This list will be later used # to execute after callbacks in reverse order. @@ -307,7 +307,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? @@ -333,7 +333,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) @@ -351,7 +351,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 17d48d2931..adaf90eb0a 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 50147b5564..b027139ef3 100644 --- a/lib/mongoid/persistable/creatable.rb +++ b/lib/mongoid/persistable/creatable.rb @@ -16,7 +16,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? @@ -48,7 +48,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? @@ -68,7 +68,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 @@ -99,7 +99,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) && @@ -139,7 +139,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) @@ -166,7 +166,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 1fd5b9a458..5b307f8c9e 100644 --- a/lib/mongoid/persistable/incrementable.rb +++ b/lib/mongoid/persistable/incrementable.rb @@ -17,7 +17,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 4d8a36693e..f2c9c8dc58 100644 --- a/lib/mongoid/persistable/logical.rb +++ b/lib/mongoid/persistable/logical.rb @@ -16,7 +16,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 1f7109013c..ff44565d83 100644 --- a/lib/mongoid/persistable/maxable.rb +++ b/lib/mongoid/persistable/maxable.rb @@ -18,7 +18,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 80231befb7..5dbde39dac 100644 --- a/lib/mongoid/persistable/minable.rb +++ b/lib/mongoid/persistable/minable.rb @@ -18,7 +18,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 787d940590..c258c76150 100644 --- a/lib/mongoid/persistable/multipliable.rb +++ b/lib/mongoid/persistable/multipliable.rb @@ -17,7 +17,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 a0bfd3658a..2757041f83 100644 --- a/lib/mongoid/persistable/poppable.rb +++ b/lib/mongoid/persistable/poppable.rb @@ -21,7 +21,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 4d881c9599..6a8e129a03 100644 --- a/lib/mongoid/persistable/pullable.rb +++ b/lib/mongoid/persistable/pullable.rb @@ -17,7 +17,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| @@ -35,7 +35,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 8c533b226e..b15c7a2e3a 100644 --- a/lib/mongoid/persistable/pushable.rb +++ b/lib/mongoid/persistable/pushable.rb @@ -16,7 +16,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| @@ -47,7 +47,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 81840f668b..33ee1ff989 100644 --- a/lib/mongoid/persistable/renamable.rb +++ b/lib/mongoid/persistable/renamable.rb @@ -17,7 +17,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 0c2e687a6e..53877a2a77 100644 --- a/lib/mongoid/persistable/settable.rb +++ b/lib/mongoid/persistable/settable.rb @@ -44,7 +44,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 44ce6cbabb..5b12b704b3 100644 --- a/lib/mongoid/persistable/unsettable.rb +++ b/lib/mongoid/persistable/unsettable.rb @@ -17,7 +17,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 f31ae88cd4..195a93cf53 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 @@ -210,7 +210,7 @@ def enforce_immutability_of_id_field! # Consolidates all the callback invocations into a single place, to # avoid cluttering the logic in #prepare_update. # - # @param [ Array ] update_children The children that the + # @param [ Array ] update_children The children that the # :update callbacks will be executed on. def run_all_callbacks_for_update(update_children) run_callbacks(:commit, with_children: true, skip_if: -> { in_transaction? }) do diff --git a/lib/mongoid/reloadable.rb b/lib/mongoid/reloadable.rb index e90b72168b..7ded689a02 100644 --- a/lib/mongoid/reloadable.rb +++ b/lib/mongoid/reloadable.rb @@ -12,7 +12,7 @@ module Reloadable # # @raise [ Errors::DocumentNotFound ] If the document was deleted. # - # @return [ Document ] The document, reloaded. + # @return [ Mongoid::Document ] The document, reloaded. def reload reloaded = _reload check_for_deleted_document!(reloaded) diff --git a/lib/mongoid/scopable.rb b/lib/mongoid/scopable.rb index 08cb8ecba1..371077f1e5 100644 --- a/lib/mongoid/scopable.rb +++ b/lib/mongoid/scopable.rb @@ -75,7 +75,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. # @@ -103,7 +103,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?) @@ -154,7 +154,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 @@ -172,7 +172,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? @@ -191,7 +191,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 @@ -203,9 +203,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) @@ -311,7 +311,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 da1a3eddbe..a70991b19d 100644 --- a/lib/mongoid/threaded.rb +++ b/lib/mongoid/threaded.rb @@ -111,7 +111,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 @@ -121,7 +121,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 @@ -131,7 +131,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 @@ -141,7 +141,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 @@ -200,7 +200,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][ @@ -216,9 +216,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 @@ -228,10 +228,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? unset_current_scope(klass) @@ -258,7 +258,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) @@ -270,7 +270,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 b61abe11f2..060432506d 100644 --- a/lib/mongoid/timestamps/timeless.rb +++ b/lib/mongoid/timestamps/timeless.rb @@ -29,7 +29,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 7a4f999a9a..bdf8915f2c 100644 --- a/lib/mongoid/traversable.rb +++ b/lib/mongoid/traversable.rb @@ -192,7 +192,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(reset: false) @@ -215,7 +215,7 @@ def _children(reset: false) # 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(reset: false) @@ -233,7 +233,7 @@ def _descendants(reset: false) # Collect all the children of this document. # - # @return [ Array ] The children. + # @return [ Array ] The children. # # @api private def collect_children @@ -249,7 +249,7 @@ def collect_children # Collect all the descendants of this document. # - # @return [ Array ] The descendants. + # @return [ Array ] The descendants. # # @api private def collect_descendants @@ -277,7 +277,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 @@ -300,9 +300,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 @@ -315,7 +315,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? @@ -330,7 +330,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 @@ -357,7 +357,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 object = object._parent while object._parent diff --git a/lib/mongoid/validatable/associated.rb b/lib/mongoid/validatable/associated.rb index f58b36a9ad..08ee3fa4f9 100644 --- a/lib/mongoid/validatable/associated.rb +++ b/lib/mongoid/validatable/associated.rb @@ -25,7 +25,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 135aa32579..3263c2b9b6 100644 --- a/lib/mongoid/validatable/localizable.rb +++ b/lib/mongoid/validatable/localizable.rb @@ -12,7 +12,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 dfcec548a4..e12ddd2d7a 100644 --- a/lib/mongoid/validatable/presence.rb +++ b/lib/mongoid/validatable/presence.rb @@ -22,7 +22,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) @@ -53,7 +53,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 7175c3184d..7ba0626047 100644 --- a/lib/mongoid/validatable/queryable.rb +++ b/lib/mongoid/validatable/queryable.rb @@ -21,7 +21,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 e527ab4681..3660cdff05 100644 --- a/lib/mongoid/validatable/uniqueness.rb +++ b/lib/mongoid/validatable/uniqueness.rb @@ -33,7 +33,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. # @@ -59,7 +59,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) @@ -88,11 +88,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)] @@ -120,11 +120,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) @@ -162,10 +162,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) @@ -181,7 +181,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) @@ -195,7 +195,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) @@ -214,7 +214,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. # @@ -235,7 +235,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) @@ -254,7 +254,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) @@ -276,7 +276,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. @@ -293,7 +293,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.