Method: ModelSet#each
- Defined in:
- lib/model_set.rb
#each ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/model_set.rb', line 149 def each num_models = ids.size ids.each_slice(MAX_CACHE_SIZE) do |slice_ids| clear_cache! if num_models > MAX_CACHE_SIZE fetch_models(slice_ids) slice_ids.each do |id| # Skip models that aren't in the database. model = models_by_id[id] if model yield model else ( @missing_ids ||= [] ) << id end end end end |