Permalink
Browse files

dry up the hash dup and avoid sending nil values

  • Loading branch information...
1 parent a56ee4c commit 5352a89d5027f87bd5794e003bf7a622e079bb8f @tenderlove tenderlove committed Aug 11, 2010
@@ -49,12 +49,16 @@ def find_target
else
"find"
end
+
+ options = @reflection.options.dup
+ (options.keys - [:select, :include, :readonly]).each do |key|
+ options.delete key
+ end
+ options[:conditions] = conditions
+
the_target = @reflection.klass.send(find_method,
@owner[@reflection.primary_key_name],
- :select => @reflection.options[:select],
- :conditions => conditions,
- :include => @reflection.options[:include],
- :readonly => @reflection.options[:readonly]
+ options
) if @owner[@reflection.primary_key_name]
set_inverse_instance(the_target, @owner)
the_target
@@ -79,13 +79,13 @@ def owner_quoted_id
private
def find_target
- the_target = @reflection.klass.find(:first,
- :conditions => @finder_sql,
- :select => @reflection.options[:select],
- :order => @reflection.options[:order],
- :include => @reflection.options[:include],
- :readonly => @reflection.options[:readonly]
- )
+ options = @reflection.options.dup
+ (options.keys - [:select, :order, :include, :readonly]).each do |key|
+ options.delete key
+ end
+ options[:conditions] = @finder_sql
+
+ the_target = @reflection.klass.find(:first, options)
set_inverse_instance(the_target, @owner)
the_target
end

0 comments on commit 5352a89

Please sign in to comment.