Permalink
Browse files

#method vs +method+ in Active Record

  • Loading branch information...
fxn committed May 19, 2008
1 parent 6760369 commit 78596747bae784196da7a184a33ef5d1b2a94107
@@ -99,7 +99,7 @@ def clear_aggregation_cache #:nodoc:
# relational unique identifiers (such as primary keys). Normal <tt>ActiveRecord::Base</tt> classes are entity objects.
#
# It's also important to treat the value objects as immutable. Don't allow the +Money+ object to have its amount changed after
- # creation. Create a new +Money+ object with the new value instead. This is exemplified by the <tt>Money#exchanged_to</tt> method that
+ # creation. Create a new Money object with the new value instead. This is exemplified by the <tt>Money#exchanged_to</tt> method that
# returns a new value object instead of changing its own values. Active Record won't persist value objects that have been
# changed through means other than the writer method.
#
@@ -1277,7 +1277,7 @@ def base_class
class_of_active_record_descendant(self)
end
- # Set this to true if this is an abstract class (see #abstract_class?).
+ # Set this to true if this is an abstract class (see <tt>abstract_class?</tt>).
attr_accessor :abstract_class
# Returns whether this class is a base AR class. If A is a base class and
@@ -1724,8 +1724,8 @@ def expand_id_conditions(id_or_conditions)
end
- # Defines an "attribute" method (like #inheritance_column or
- # #table_name). A new (class) method will be created with the
+ # Defines an "attribute" method (like +inheritance_column+ or
+ # +table_name+). A new (class) method will be created with the
# given name. If a value is specified, the new method will
# return that value (as a string). Otherwise, the given block
# will be used to compute the value of the method.
@@ -46,28 +46,28 @@ def count(*args)
calculate(:count, *construct_count_options_from_args(*args))
end
- # Calculates the average value on a given column. The value is returned as a float. See #calculate for examples with options.
+ # Calculates the average value on a given column. The value is returned as a float. See +calculate+ for examples with options.
#
# Person.average('age')
def average(column_name, options = {})
calculate(:avg, column_name, options)
end
- # Calculates the minimum value on a given column. The value is returned with the same data type of the column. See #calculate for examples with options.
+ # Calculates the minimum value on a given column. The value is returned with the same data type of the column. See +calculate+ for examples with options.
#
# Person.minimum('age')
def minimum(column_name, options = {})
calculate(:min, column_name, options)
end
- # Calculates the maximum value on a given column. The value is returned with the same data type of the column. See #calculate for examples with options.
+ # Calculates the maximum value on a given column. The value is returned with the same data type of the column. See +calculate+ for examples with options.
#
# Person.maximum('age')
def maximum(column_name, options = {})
calculate(:max, column_name, options)
end
- # Calculates the sum of values on a given column. The value is returned with the same data type of the column. See #calculate for examples with options.
+ # Calculates the sum of values on a given column. The value is returned with the same data type of the column. See +calculate+ for examples with options.
#
# Person.sum('age')
def sum(column_name, options = {})
@@ -161,7 +161,7 @@ module ActiveRecord
# == <tt>before_validation*</tt> returning statements
#
# If the returning value of a +before_validation+ callback can be evaluated to +false+, the process will be aborted and <tt>Base#save</tt> will return +false+.
- # If <tt>Base#save!</tt> is called it will raise a +RecordNotSaved+ exception.
+ # If Base#save! is called it will raise a RecordNotSaved exception.
# Nothing will be appended to the errors object.
#
# == Canceling callbacks
@@ -29,7 +29,7 @@ def select_values(sql, name = nil)
end
# Returns an array of arrays containing the field values.
- # Order is the same as that returned by #columns.
+ # Order is the same as that returned by +columns+.
def select_rows(sql, name = nil)
raise NotImplementedError, "select_rows is an abstract method"
end
@@ -93,7 +93,7 @@ def commit_db_transaction() end
# done if the transaction block raises an exception or returns false.
def rollback_db_transaction() end
- # Alias for #add_limit_offset!.
+ # Alias for <tt>add_limit_offset!</tt>.
def add_limit!(sql, options)
add_limit_offset!(sql, options) if options
end
@@ -270,7 +270,7 @@ def add_column_options!(sql, options)
end
# Represents a SQL table in an abstract way.
- # Columns are stored as a ColumnDefinition in the #columns attribute.
+ # Columns are stored as a ColumnDefinition in the +columns+ attribute.
class TableDefinition
attr_accessor :columns
@@ -395,7 +395,7 @@ def [](name)
# end
#
# There's a short-hand method for each of the type values declared at the top. And then there's
- # TableDefinition#timestamps that'll add created_at and updated_at as datetimes.
+ # TableDefinition#timestamps that'll add created_at and +updated_at+ as datetimes.
#
# TableDefinition#references will add an appropriately-named _id column, plus a corresponding _type
# column if the <tt>:polymorphic</tt> option is supplied. If <tt>:polymorphic</tt> is a hash of options, these will be
@@ -32,7 +32,7 @@ def table_exists?(table_name)
def columns(table_name, name = nil) end
# Creates a new table
- # There are two ways to work with #create_table. You can use the block
+ # There are two ways to work with +create_table+. You can use the block
# form or the regular form, like this:
#
# === Block form
@@ -107,20 +107,20 @@ class <<base
end
# Is optimistic locking enabled for this table? Returns true if the
- # #lock_optimistically flag is set to true (which it is, by default)
- # and the table includes the #locking_column column (defaults to
- # lock_version).
+ # +lock_optimistically+ flag is set to true (which it is, by default)
+ # and the table includes the +locking_column+ column (defaults to
+ # +lock_version+).
def locking_enabled?
lock_optimistically && columns_hash[locking_column]
end
- # Set the column to use for optimistic locking. Defaults to lock_version.
+ # Set the column to use for optimistic locking. Defaults to +lock_version+.
def set_locking_column(value = nil, &block)
define_attr_method :locking_column, value, &block
value
end
- # The version column used for optimistic locking. Defaults to lock_version.
+ # The version column used for optimistic locking. Defaults to +lock_version+.
def locking_column
reset_locking_column
end
@@ -130,12 +130,12 @@ def quoted_locking_column
connection.quote_column_name(locking_column)
end
- # Reset the column used for optimistic locking back to the lock_version default.
+ # Reset the column used for optimistic locking back to the +lock_version+ default.
def reset_locking_column
set_locking_column DEFAULT_LOCKING_COLUMN
end
- # make sure the lock version column gets updated when counters are
+ # Make sure the lock version column gets updated when counters are
# updated.
def update_counters_with_lock(id, counters)
counters = counters.merge(locking_column => 1) if locking_enabled?
@@ -208,7 +208,7 @@ def initialize(name)
#
# You can quiet them down by setting ActiveRecord::Migration.verbose = false.
#
- # You can also insert your own messages and benchmarks by using the #say_with_time
+ # You can also insert your own messages and benchmarks by using the +say_with_time+
# method:
#
# def self.up
@@ -19,7 +19,7 @@ module ClassMethods
# # Same as above, just using explicit class references
# ActiveRecord::Base.observers = Cacher, GarbageCollector
#
- # Note: Setting this does not instantiate the observers yet. #instantiate_observers is
+ # Note: Setting this does not instantiate the observers yet. +instantiate_observers+ is
# called during startup, and before each development request.
def observers=(*observers)
@observers = observers.flatten
@@ -30,8 +30,8 @@ class Schema < Migration
# Eval the given block. All methods available to the current connection
# adapter are available within the block, so you can easily use the
- # database definition DSL to build up your schema (#create_table,
- # #add_index, etc.).
+ # database definition DSL to build up your schema (+create_table+,
+ # +add_index+, etc.).
#
# The +info+ hash is optional, and if given is used to define metadata
# about the current schema (currently, only the schema's version):
@@ -273,14 +273,14 @@ def initialize(name, record)
end
# There is a significant speed improvement if the value
- # does not need to be escaped, as #tag! escapes all values
+ # does not need to be escaped, as <tt>tag!</tt> escapes all values
# to ensure that valid XML is generated. For known binary
# values, it is at least an order of magnitude faster to
# Base64 encode binary values and directly put them in the
# output XML than to pass the original value or the Base64
- # encoded value to the #tag! method. It definitely makes
+ # encoded value to the <tt>tag!</tt> method. It definitely makes
# no sense to Base64 encode the value and then give it to
- # #tag!, since that just adds additional overhead.
+ # <tt>tag!</tt>, since that just adds additional overhead.
def needs_encoding?
![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type)
end
@@ -301,7 +301,7 @@ module ClassMethods
:odd => 'odd?', :even => 'even?' }.freeze
# Adds a validation method or block to the class. This is useful when
- # overriding the #validate instance method becomes too unwieldly and
+ # overriding the +validate+ instance method becomes too unwieldly and
# you're looking for more descriptive declaration of your validations.
#
# This can be done with a symbol pointing to a method:
@@ -326,7 +326,7 @@ module ClassMethods
# end
# end
#
- # This usage applies to #validate_on_create and #validate_on_update as well.
+ # This usage applies to +validate_on_create+ and +validate_on_update+ as well.
# Validates each attribute against a block.
#

0 comments on commit 7859674

Please sign in to comment.