From 070dda28ae1762b9c6a7e40aeeedc5bb57c15147 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 10 Apr 2013 14:33:39 -0400 Subject: [PATCH] rdoc for some of the methods in JoinDependency --- .../associations/join_dependency.rb | 21 +++++++++++++++++++ .../join_dependency/join_association.rb | 15 +++++++++++++ 2 files changed, 36 insertions(+) diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 93b088790e..28e081c03c 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -7,6 +7,27 @@ module ActiveRecord attr_reader :join_parts, :reflections, :alias_tracker, :base_klass + # base is the base class on which operation is taking place. + # associations is the list of associations which are joined using hash, symbol or array. + # joins is the list of all string join commnads and arel nodes. + # + # Example : + # + # class Physician < ActiveRecord::Base + # has_many :appointments + # has_many :patients, through: :appointments + # end + # + # If I execute `@physician.patients.to_a` then + # base #=> Physician + # associations #=> [] + # joins #=> [# Physician + # associations #=> [:appointments] + # joins #=> [] + # def initialize(base, associations, joins) @base_klass = base @table_joins = joins diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index ae1b38ff86..e4d17451dc 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -123,6 +123,21 @@ module ActiveRecord manager end + # Builds equality condition. + # + # Example: + # + # class Physician < ActiveRecord::Base + # has_many :appointments + # end + # + # If I execute `Physician.joins(:appointments).to_a` then + # reflection #=> # + # table #=> # + # key #=> physician_id + # foreign_table #=> # + # foreign_key #=> id + # def build_constraint(reflection, table, key, foreign_table, foreign_key) constraint = table[key].eq(foreign_table[foreign_key])