class NoBrainer::Criteria::OrderBy::IndexFinder
Public Instance Methods
could_find_index?()
click to toggle source
# File lib/no_brainer/criteria/order_by.rb, line 65 def could_find_index? !!self.index_name end
find_index()
click to toggle source
# File lib/no_brainer/criteria/order_by.rb, line 79 def find_index return if criteria.without_index? return unless first_key_indexable? if criteria.options[:use_index] && criteria.options[:use_index] != true return unless first_key.to_s == criteria.options[:use_index].to_s end # We need make sure that the where index finder has been invoked, it has priority. # If it doesn't find anything, we are free to go with our indexes. if !criteria.where_indexed? || (criteria.where_index_type == :between && first_key.to_s == criteria.where_index_name.to_s) self.index_name = first_key end end
first_key()
click to toggle source
# File lib/no_brainer/criteria/order_by.rb, line 69 def first_key @first_key ||= criteria.__send__(:effective_order).to_a.first.try(:[], 0) end
first_key_indexable?()
click to toggle source
# File lib/no_brainer/criteria/order_by.rb, line 73 def first_key_indexable? return false unless first_key.is_a?(Symbol) || first_key.is_a?(String) return false unless index = criteria.model.indexes[first_key.to_sym] return !index.multi && !index.geo end