Skip to content

Commit

Permalink
dry up the hash dup and avoid sending nil values
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Aug 11, 2010
1 parent a56ee4c commit 5352a89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit 5352a89

Please sign in to comment.