diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-01-02 14:42:17 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-03 16:24:31 -0800 |
commit | 4e194ed1e68c13901f486334a5a1e9f509b10722 (patch) | |
tree | c11aa6b9e3df716b1319bd1108099f5117449016 /activerecord/lib | |
parent | a0be389d39b790e0625339251d2674b8250b16b1 (diff) | |
download | rails-4e194ed1e68c13901f486334a5a1e9f509b10722.tar.gz rails-4e194ed1e68c13901f486334a5a1e9f509b10722.tar.bz2 rails-4e194ed1e68c13901f486334a5a1e9f509b10722.zip |
Rename AssociationProxy#foreign_key_present to foreign_key_present?
Diffstat (limited to 'activerecord/lib')
4 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 0959ea2c5a..be5d264a8f 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -364,7 +364,7 @@ module ActiveRecord end def load_target - if !@owner.new_record? || foreign_key_present + if !@owner.new_record? || foreign_key_present? begin unless loaded? if @target.is_a?(Array) && @target.any? diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index 65fef81d64..e86f4c0283 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -270,7 +270,7 @@ module ActiveRecord def load_target return nil unless defined?(@loaded) - if !loaded? && (!@owner.new_record? || foreign_key_present) && @scope + if !loaded? && (!@owner.new_record? || foreign_key_present?) && @scope @target = find_target end @@ -287,7 +287,7 @@ module ActiveRecord # # Currently implemented by belongs_to (vanilla and polymorphic) and # has_one/has_many :through associations which go through a belongs_to - def foreign_key_present + def foreign_key_present? false end diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb index c54e397ae4..98b846f97c 100644 --- a/activerecord/lib/active_record/associations/belongs_to_association.rb +++ b/activerecord/lib/active_record/associations/belongs_to_association.rb @@ -38,7 +38,7 @@ module ActiveRecord record.class.increment_counter(counter_cache_name, record.id) end - if foreign_key_present + if foreign_key_present? target_klass.decrement_counter(counter_cache_name, target_id) end end @@ -55,7 +55,7 @@ module ActiveRecord end def find_target - if foreign_key_present + if foreign_key_present? scoped.first.tap { |record| set_inverse_instance(record) } end end @@ -77,7 +77,7 @@ module ActiveRecord conditions end - def foreign_key_present + def foreign_key_present? !@owner[@reflection.foreign_key].nil? end diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb index 0d83b46130..2b28dda363 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -152,7 +152,7 @@ module ActiveRecord end end - def foreign_key_present + def foreign_key_present? @reflection.through_reflection.macro == :belongs_to && !@owner[@reflection.through_reflection.foreign_key].nil? end |