From c326969745c38aaca552aebf240af644440afab3 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 14 Jan 2011 14:45:46 -0800 Subject: reduce funcalls by using falsey objects --- activerecord/lib/active_record/associations/belongs_to_association.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb index 391471849c..b5545f4084 100644 --- a/activerecord/lib/active_record/associations/belongs_to_association.rb +++ b/activerecord/lib/active_record/associations/belongs_to_association.rb @@ -12,7 +12,7 @@ module ActiveRecord def replace(record) record = record.target if AssociationProxy === record - raise_on_type_mismatch(record) unless record.nil? + raise_on_type_mismatch(record) if record update_counters(record) replace_keys(record) @@ -59,7 +59,7 @@ module ActiveRecord end def foreign_key_present? - !@owner[@reflection.foreign_key].nil? + @owner[@reflection.foreign_key] end # NOTE - for now, we're only supporting inverse setting from belongs_to back onto -- cgit v1.2.3