Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refactored `include?` logic in HasMany

  • Loading branch information...
commit aa91f23d80e960fa06f4e29c79d0abc34dc78ebd 1 parent 2639370
Alex Serebryakov serebryakov authored

Showing 1 changed file with 3 additions and 3 deletions. Show diff stats Hide diff stats

  1. +3 3 lib/lib/associations/has_many.rb
6 lib/lib/associations/has_many.rb
@@ -98,8 +98,7 @@ def create
98 98 # Returns true if a given object is present in the collection
99 99 ##
100 100 def include?(object)
101   - @value ||= []
102   - @value.include?(object)
  101 + value.include?(object)
103 102 end
104 103
105 104 ##
@@ -135,11 +134,12 @@ def value
135 134 if @instance.id.nil?
136 135 return []
137 136 end
  137 + @value = []
138 138 replace @association.find(:all, {
139 139 :conditions => { reverse => @instance },
140 140 :skip => [reverse]
141 141 })
142   - @value || []
  142 + @value
143 143 end
144 144
145 145 ##

0 comments on commit aa91f23

Please sign in to comment.
Something went wrong with that request. Please try again.