module NoBrainer::Criteria::Index

Public Instance Methods

compile_rql_pass2() click to toggle source
Calls superclass method
# File lib/no_brainer/criteria/index.rb, line 23
def compile_rql_pass2
  super.tap do
    # The implicit ordering on the indexed pk does not count.
    if @options[:use_index] && (!used_index || order_by_index_name.to_s == model.pk_name.to_s)
      raise NoBrainer::Error::CannotUseIndex.new(@options[:use_index])
    end
  end
end
used_index() click to toggle source
# File lib/no_brainer/criteria/index.rb, line 18
def used_index
  # Only one of them will be active.
  where_index_name || order_by_index_name
end
with_index(index_name=true) click to toggle source
# File lib/no_brainer/criteria/index.rb, line 6
def with_index(index_name=true)
  chain(:use_index => index_name)
end
without_index() click to toggle source
# File lib/no_brainer/criteria/index.rb, line 10
def without_index
  with_index(false)
end
without_index?() click to toggle source
# File lib/no_brainer/criteria/index.rb, line 14
def without_index?
  finalized_criteria.options[:use_index] == false
end