Method: SearchFlip::Index::ClassMethods#each_record
- Defined in:
- lib/search_flip/index.rb
#each_record(scope, index_scope: false) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used to iterate a record set. Here, a record set may be a) an ActiveRecord::Relation or anything responding to #find_each, b) an Array of records or anything responding to #each or c) a single record.
155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/search_flip/index.rb', line 155 def each_record(scope, index_scope: false) return enum_for(:each_record, scope) unless block_given? if scope.respond_to?(:find_each) (index_scope ? self.index_scope(scope) : scope).find_each do |record| yield record end else (scope.respond_to?(:each) && !scope.is_a?(SearchFlip::Result) ? scope : Array(scope)).each do |record| yield record end end end |