Permalink
Browse files

Refactored `include?` logic in HasMany

  • Loading branch information...
serebryakov committed May 28, 2010
1 parent 2639370 commit aa91f23d80e960fa06f4e29c79d0abc34dc78ebd
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/lib/associations/has_many.rb
@@ -98,8 +98,7 @@ def create
# Returns true if a given object is present in the collection
##
def include?(object)
- @value ||= []
- @value.include?(object)
+ value.include?(object)
end
##
@@ -135,11 +134,12 @@ def value
if @instance.id.nil?
return []
end
+ @value = []
replace @association.find(:all, {
:conditions => { reverse => @instance },
:skip => [reverse]
})
- @value || []
+ @value
end
##

0 comments on commit aa91f23

Please sign in to comment.