aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-05-23 22:43:08 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-05-23 22:43:08 +0530
commit1ad0b378cc081937c117577ab628f2160fcc448d (patch)
treea675d20ea606caa653010c57b90d10f173f7dd93 /activerecord/lib/active_record/reflection.rb
parent2642c2961cda2074cc1495a4635898ca8ab33adf (diff)
downloadrails-1ad0b378cc081937c117577ab628f2160fcc448d.tar.gz
rails-1ad0b378cc081937c117577ab628f2160fcc448d.tar.bz2
rails-1ad0b378cc081937c117577ab628f2160fcc448d.zip
Revert "Remove blank trailing comments"
This reverts commit fa6d921e11363e9b8c4bc10f7aed0b9faffdc33a. Reason: Not a fan of such massive changes. We usually close such changes if made to Rails master as a pull request. Following the same principle here and reverting. [ci skip]
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r--activerecord/lib/active_record/reflection.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 17e388a1d4..c380b5c029 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -42,6 +42,7 @@ module ActiveRecord
# Returns the AggregateReflection object for the named +aggregation+ (use the symbol).
#
# Account.reflect_on_aggregation(:balance) # => the balance AggregateReflection
+ #
def reflect_on_aggregation(aggregation)
reflection = reflections[aggregation]
reflection if reflection.is_a?(AggregateReflection)
@@ -56,6 +57,7 @@ module ActiveRecord
#
# Account.reflect_on_all_associations # returns an array of all associations
# Account.reflect_on_all_associations(:has_many) # returns an array of all has_many associations
+ #
def reflect_on_all_associations(macro = nil)
association_reflections = reflections.values.grep(AssociationReflection)
macro ? association_reflections.select { |reflection| reflection.macro == macro } : association_reflections
@@ -65,6 +67,7 @@ module ActiveRecord
#
# Account.reflect_on_association(:owner) # returns the owner AssociationReflection
# Invoice.reflect_on_association(:line_items).macro # returns :has_many
+ #
def reflect_on_association(association)
reflection = reflections[association]
reflection if reflection.is_a?(AssociationReflection)
@@ -383,6 +386,7 @@ module ActiveRecord
# has_many :taggings
# has_many :tags, :through => :taggings
# end
+ #
def source_reflection
@source_reflection ||= source_reflection_names.collect { |name| through_reflection.klass.reflect_on_association(name) }.compact.first
end
@@ -397,6 +401,7 @@ module ActiveRecord
#
# tags_reflection = Post.reflect_on_association(:tags)
# taggings_reflection = tags_reflection.through_reflection
+ #
def through_reflection
@through_reflection ||= active_record.reflect_on_association(options[:through])
end
@@ -483,6 +488,7 @@ module ActiveRecord
# Gets an array of possible <tt>:through</tt> source reflection names:
#
# [:singularized, :pluralized]
+ #
def source_reflection_names
@source_reflection_names ||= (options[:source] ? [options[:source]] : [name.to_s.singularize, name]).collect { |n| n.to_sym }
end