aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRizwan Reza <rizwanreza@gmail.com>2010-06-16 22:08:14 +0430
committerRizwan Reza <rizwanreza@gmail.com>2010-06-16 22:08:14 +0430
commitd8277804b2ad95275d21492f4d925d1148425253 (patch)
treec2978824a9949e37a6f47597c3315df14022df35 /activerecord
parent317a75bf5860a9ab5d5535ccb4aedfabc83644d6 (diff)
downloadrails-d8277804b2ad95275d21492f4d925d1148425253.tar.gz
rails-d8277804b2ad95275d21492f4d925d1148425253.tar.bz2
rails-d8277804b2ad95275d21492f4d925d1148425253.zip
Adds title and minor changes.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/migration.rb2
-rw-r--r--activerecord/lib/active_record/named_scope.rb11
-rw-r--r--activerecord/lib/active_record/nested_attributes.rb3
-rw-r--r--activerecord/lib/active_record/observer.rb2
-rw-r--r--activerecord/lib/active_record/persistence.rb29
5 files changed, 30 insertions, 17 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index 4a1d6ac758..b273c33e50 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -29,7 +29,7 @@ module ActiveRecord
end
end
- # Active Record Migrations
+ # = Active Record Migrations
#
# Migrations can manage the evolution of a schema used by several physical
# databases. It's a solution to the common problem of adding a field to make
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb
index 3d8f4a030b..096b9da402 100644
--- a/activerecord/lib/active_record/named_scope.rb
+++ b/activerecord/lib/active_record/named_scope.rb
@@ -4,11 +4,12 @@ require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/object/blank'
module ActiveRecord
+ # = Active Record Named Scopes
module NamedScope
extend ActiveSupport::Concern
module ClassMethods
- # Returns an anonymous scope.
+ # Returns an anonymous \scope.
#
# posts = Post.scoped
# posts.size # Fires "select count(*) from posts" and returns the count
@@ -18,10 +19,12 @@ module ActiveRecord
# fruits = fruits.where(:colour => 'red') if options[:red_only]
# fruits = fruits.limit(10) if limited?
#
- # Anonymous \scopes tend to be useful when procedurally generating complex queries, where passing
- # intermediate values (scopes) around as first-class objects is convenient.
+ # Anonymous scopes tend to be useful when procedurally generating complex
+ # queries, where passing intermediate values (scopes) around as first-class
+ # objects is convenient.
#
- # You can define a scope that applies to all finders using ActiveRecord::Base.default_scope.
+ # You can define a scope that applies to all finders using
+ # ActiveRecord::Base.default_scope.
def scoped(options = {}, &block)
if options.present?
relation = scoped.apply_finder_options(options)
diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb
index 767ec85432..99f8b431c8 100644
--- a/activerecord/lib/active_record/nested_attributes.rb
+++ b/activerecord/lib/active_record/nested_attributes.rb
@@ -15,7 +15,7 @@ module ActiveRecord
self.nested_attributes_options = {}
end
- # == Nested Attributes
+ # = Active Record Nested Attributes
#
# Nested attributes allow you to save attributes on associated records
# through the parent. By default nested attribute updating is turned off,
@@ -25,6 +25,7 @@ module ActiveRecord
#
# The attribute writer is named after the association, which means that
# in the following example, two new methods are added to your model:
+ #
# <tt>author_attributes=(attributes)</tt> and
# <tt>pages_attributes=(attributes)</tt>.
#
diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb
index 0ea7fe7365..9554dd8826 100644
--- a/activerecord/lib/active_record/observer.rb
+++ b/activerecord/lib/active_record/observer.rb
@@ -1,6 +1,8 @@
require 'active_support/core_ext/class/attribute'
module ActiveRecord
+ # = Active Record Observer
+ #
# Observer classes respond to lifecycle callbacks to implement trigger-like
# behavior outside the original class. This is a great way to reduce the
# clutter that normally comes when the model class is burdened with
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 10788630a5..9e28aa2a05 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -1,6 +1,8 @@
module ActiveRecord
+ # = Active Record Persistence
module Persistence
- # Returns true if this object hasn't been saved yet -- that is, a record for the object doesn't exist yet; otherwise, returns false.
+ # Returns true if this object hasn't been saved yet -- that is, a record
+ # for the object doesn't exist in the data store yet; otherwise, returns false.
def new_record?
@new_record
end
@@ -10,7 +12,8 @@ module ActiveRecord
@destroyed
end
- # Returns if the record is persisted, i.e. it's not a new record and it was not destroyed.
+ # Returns if the record is persisted, i.e. it's not a new record and it was
+ # not destroyed.
def persisted?
!(new_record? || destroyed?)
end
@@ -69,8 +72,8 @@ module ActiveRecord
freeze
end
- # Deletes the record in the database and freezes this instance to reflect that no changes should
- # be made (since they can't be persisted).
+ # Deletes the record in the database and freezes this instance to reflect
+ # that no changes should be made (since they can't be persisted).
def destroy
if persisted?
self.class.unscoped.where(self.class.arel_table[self.class.primary_key].eq(id)).delete_all
@@ -80,10 +83,13 @@ module ActiveRecord
freeze
end
- # Returns an instance of the specified +klass+ with the attributes of the current record. This is mostly useful in relation to
- # single-table inheritance structures where you want a subclass to appear as the superclass. This can be used along with record
- # identification in Action Pack to allow, say, <tt>Client < Company</tt> to do something like render <tt>:partial => @client.becomes(Company)</tt>
- # to render that instance using the companies/company partial instead of clients/client.
+ # Returns an instance of the specified +klass+ with the attributes of the
+ # current record. This is mostly useful in relation to single-table
+ # inheritance structures where you want a subclass to appear as the
+ # superclass. This can be used along with record identification in
+ # Action Pack to allow, say, <tt>Client < Company</tt> to do something
+ # like render <tt>:partial => @client.becomes(Company)</tt> to render that
+ # instance using the companies/company partial instead of clients/client.
#
# Note: The new instance will share a link to the same attributes as the original class. So any change to the attributes in either
# instance will affect the other.
@@ -104,14 +110,15 @@ module ActiveRecord
save(:validate => false)
end
- # Updates all the attributes from the passed-in Hash and saves the record. If the object is invalid, the saving will
- # fail and false will be returned.
+ # Updates all the attributes from the passed-in Hash and saves the record.
+ # If the object is invalid, the saving will fail and false will be returned.
def update_attributes(attributes)
self.attributes = attributes
save
end
- # Updates an object just like Base.update_attributes but calls save! instead of save so an exception is raised if the record is invalid.
+ # Updates an object just like Base.update_attributes but calls save! instead
+ # of save so an exception is raised if the record is invalid.
def update_attributes!(attributes)
self.attributes = attributes
save!