提交 e216b00a 编写于 作者: F Francesco Rodriguez

fix AR::Associations::CollectionProxy#delete broken documentation [ci skip]

上级 08035482
...@@ -51,7 +51,6 @@ def loaded? ...@@ -51,7 +51,6 @@ def loaded?
@association.loaded? @association.loaded?
end end
##
# Works in two ways. # Works in two ways.
# #
# *First:* Specify a subset of fields to be selected from the result set. # *First:* Specify a subset of fields to be selected from the result set.
...@@ -109,9 +108,8 @@ def select(select = nil, &block) ...@@ -109,9 +108,8 @@ def select(select = nil, &block)
@association.select(select, &block) @association.select(select, &block)
end end
##
# Finds an object in the collection responding to the +id+. Uses the same # Finds an object in the collection responding to the +id+. Uses the same
# rules as +ActiveRecord::Base.find+. Returns +ActiveRecord::RecordNotFound++ # rules as <tt>ActiveRecord::Base.find</tt>. Returns <tt>ActiveRecord::RecordNotFound</tt>
# error if the object can not be found. # error if the object can not be found.
# #
# class Person < ActiveRecord::Base # class Person < ActiveRecord::Base
...@@ -140,7 +138,6 @@ def find(*args, &block) ...@@ -140,7 +138,6 @@ def find(*args, &block)
@association.find(*args, &block) @association.find(*args, &block)
end end
##
# Returns the first record, or the first +n+ records, from the collection. # Returns the first record, or the first +n+ records, from the collection.
# If the collection is empty, the first form returns +nil+, and the second # If the collection is empty, the first form returns +nil+, and the second
# form returns an empty array. # form returns an empty array.
...@@ -171,7 +168,6 @@ def first(*args) ...@@ -171,7 +168,6 @@ def first(*args)
@association.first(*args) @association.first(*args)
end end
##
# Returns the last record, or the last +n+ records, from the collection. # Returns the last record, or the last +n+ records, from the collection.
# If the collection is empty, the first form returns +nil+, and the second # If the collection is empty, the first form returns +nil+, and the second
# form returns an empty array. # form returns an empty array.
...@@ -202,7 +198,6 @@ def last(*args) ...@@ -202,7 +198,6 @@ def last(*args)
@association.last(*args) @association.last(*args)
end end
##
# Returns a new object of the collection type that has been instantiated # Returns a new object of the collection type that has been instantiated
# with +attributes+ and linked to this object, but have not yet been saved. # with +attributes+ and linked to this object, but have not yet been saved.
# You can pass an array of attributes hashes, this will return an array # You can pass an array of attributes hashes, this will return an array
...@@ -231,7 +226,6 @@ def build(attributes = {}, &block) ...@@ -231,7 +226,6 @@ def build(attributes = {}, &block)
@association.build(attributes, &block) @association.build(attributes, &block)
end end
##
# Returns a new object of the collection type that has been instantiated with # Returns a new object of the collection type that has been instantiated with
# attributes, linked to this object and that has already been saved (if it # attributes, linked to this object and that has already been saved (if it
# passes the validations). # passes the validations).
...@@ -262,7 +256,6 @@ def create(attributes = {}, &block) ...@@ -262,7 +256,6 @@ def create(attributes = {}, &block)
@association.create(attributes, &block) @association.create(attributes, &block)
end end
##
# Like +create+, except that if the record is invalid, raises an exception. # Like +create+, except that if the record is invalid, raises an exception.
# #
# class Person # class Person
...@@ -279,7 +272,6 @@ def create!(attributes = {}, &block) ...@@ -279,7 +272,6 @@ def create!(attributes = {}, &block)
@association.create!(attributes, &block) @association.create!(attributes, &block)
end end
##
# Add one or more records to the collection by setting their foreign keys # Add one or more records to the collection by setting their foreign keys
# to the association's primary key. Since << flattens its argument list and # to the association's primary key. Since << flattens its argument list and
# inserts each record, +push+ and +concat+ behave identically. Returns +self+ # inserts each record, +push+ and +concat+ behave identically. Returns +self+
...@@ -308,7 +300,6 @@ def concat(*records) ...@@ -308,7 +300,6 @@ def concat(*records)
@association.concat(*records) @association.concat(*records)
end end
##
# Replace this collection with +other_array+. This will perform a diff # Replace this collection with +other_array+. This will perform a diff
# and delete/add only records that have changed. # and delete/add only records that have changed.
# #
...@@ -335,7 +326,6 @@ def replace(other_array) ...@@ -335,7 +326,6 @@ def replace(other_array)
@association.replace(other_array) @association.replace(other_array)
end end
##
# Deletes all the records from the collection. For +has_many+ associations, # Deletes all the records from the collection. For +has_many+ associations,
# the deletion is done according to the strategy specified by the <tt>:dependent</tt> # the deletion is done according to the strategy specified by the <tt>:dependent</tt>
# option. Returns an array with the deleted records. # option. Returns an array with the deleted records.
...@@ -428,7 +418,6 @@ def delete_all ...@@ -428,7 +418,6 @@ def delete_all
@association.delete_all @association.delete_all
end end
##
# Deletes the records of the collection directly from the database. # Deletes the records of the collection directly from the database.
# This will _always_ remove the records ignoring the +:dependent+ # This will _always_ remove the records ignoring the +:dependent+
# option. # option.
...@@ -455,7 +444,6 @@ def destroy_all ...@@ -455,7 +444,6 @@ def destroy_all
@association.destroy_all @association.destroy_all
end end
##
# Deletes the +records+ supplied and removes them from the collection. For # Deletes the +records+ supplied and removes them from the collection. For
# +has_many+ associations, the deletion is done according to the strategy # +has_many+ associations, the deletion is done according to the strategy
# specified by the <tt>:dependent</tt> option. Returns an array with the # specified by the <tt>:dependent</tt> option. Returns an array with the
...@@ -519,7 +507,7 @@ def destroy_all ...@@ -519,7 +507,7 @@ def destroy_all
# Pet.find(1, 3) # Pet.find(1, 3)
# # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (1, 3) # # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (1, 3)
# #
# If it is set to <tt>:delete_all</tt>, all the +records+ are deleted # If it is set to <tt>:delete_all</tt>, all the +records+ are deleted
# *without* calling their +destroy+ method. # *without* calling their +destroy+ method.
# #
# class Person < ActiveRecord::Base # class Person < ActiveRecord::Base
...@@ -574,7 +562,6 @@ def delete(*records) ...@@ -574,7 +562,6 @@ def delete(*records)
@association.delete(*records) @association.delete(*records)
end end
##
# Destroys the +records+ supplied and removes them from the collection. # Destroys the +records+ supplied and removes them from the collection.
# This method will _always_ remove record from the database ignoring # This method will _always_ remove record from the database ignoring
# the +:dependent+ option. Returns an array with the removed records. # the +:dependent+ option. Returns an array with the removed records.
...@@ -647,7 +634,6 @@ def destroy(*records) ...@@ -647,7 +634,6 @@ def destroy(*records)
@association.destroy(*records) @association.destroy(*records)
end end
##
# Specifies whether the records should be unique or not. # Specifies whether the records should be unique or not.
# #
# class Person < ActiveRecord::Base # class Person < ActiveRecord::Base
...@@ -666,7 +652,6 @@ def uniq ...@@ -666,7 +652,6 @@ def uniq
@association.uniq @association.uniq
end end
##
# Count all records using SQL. # Count all records using SQL.
# #
# class Person < ActiveRecord::Base # class Person < ActiveRecord::Base
...@@ -684,7 +669,6 @@ def count(column_name = nil, options = {}) ...@@ -684,7 +669,6 @@ def count(column_name = nil, options = {})
@association.count(column_name, options) @association.count(column_name, options)
end end
##
# Returns the size of the collection. If the collection hasn't been loaded, # Returns the size of the collection. If the collection hasn't been loaded,
# it executes a <tt>SELECT COUNT(*)</tt> query. # it executes a <tt>SELECT COUNT(*)</tt> query.
# #
...@@ -709,7 +693,6 @@ def size ...@@ -709,7 +693,6 @@ def size
@association.size @association.size
end end
##
# Returns the size of the collection calling +size+ on the target. # Returns the size of the collection calling +size+ on the target.
# If the collection has been already loaded, +length+ and +size+ are # If the collection has been already loaded, +length+ and +size+ are
# equivalent. # equivalent.
...@@ -733,7 +716,6 @@ def length ...@@ -733,7 +716,6 @@ def length
@association.length @association.length
end end
##
# Returns +true+ if the collection is empty. # Returns +true+ if the collection is empty.
# #
# class Person < ActiveRecord::Base # class Person < ActiveRecord::Base
...@@ -751,7 +733,6 @@ def empty? ...@@ -751,7 +733,6 @@ def empty?
@association.empty? @association.empty?
end end
##
# Returns +true+ if the collection is not empty. # Returns +true+ if the collection is not empty.
# #
# class Person < ActiveRecord::Base # class Person < ActiveRecord::Base
...@@ -785,7 +766,6 @@ def any?(&block) ...@@ -785,7 +766,6 @@ def any?(&block)
@association.any?(&block) @association.any?(&block)
end end
##
# Returns true if the collection has more than one record. # Returns true if the collection has more than one record.
# Equivalent to <tt>collection.size > 1</tt>. # Equivalent to <tt>collection.size > 1</tt>.
# #
...@@ -824,7 +804,6 @@ def many?(&block) ...@@ -824,7 +804,6 @@ def many?(&block)
@association.many?(&block) @association.many?(&block)
end end
##
# Returns +true+ if the given object is present in the collection. # Returns +true+ if the given object is present in the collection.
# #
# class Person < ActiveRecord::Base # class Person < ActiveRecord::Base
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册