Module: NoBrainer::Criteria::Where

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::ForbiddenAttributesProtection
Defined in:
lib/no_brainer/criteria/where.rb

Defined Under Namespace

Classes: BinaryOperator, IndexFinder, Lambda, MultiOperator, UnaryOperator

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.merge_where_ast(a, b) ⇒ Object



18
19
20
# File 'lib/no_brainer/criteria/where.rb', line 18

def self.merge_where_ast(a, b)
  (a ? MultiOperator.new(:and, [a, b]) : b).simplify
end

Instance Method Details

#_where(*args, &block) ⇒ Object



14
15
16
# File 'lib/no_brainer/criteria/where.rb', line 14

def _where(*args, &block)
  chain(:where_ast => parse_clause([*args, block].compact, :unsafe => true))
end

#where(*args, &block) ⇒ Object



10
11
12
# File 'lib/no_brainer/criteria/where.rb', line 10

def where(*args, &block)
  chain(:where_ast => parse_clause([*args, block].compact))
end

#where_index_nameObject



30
31
32
33
# File 'lib/no_brainer/criteria/where.rb', line 30

def where_index_name
  index = where_index_finder.strategy.try(:index)
  index.is_a?(Array) ? index.map(&:name) : index.try(:name)
end

#where_index_typeObject



35
36
37
# File 'lib/no_brainer/criteria/where.rb', line 35

def where_index_type
  where_index_finder.strategy.try(:rql_op)
end

#where_indexed?Boolean

Returns:



26
27
28
# File 'lib/no_brainer/criteria/where.rb', line 26

def where_indexed?
  where_index_name.present?
end

#where_present?Boolean

Returns:



22
23
24
# File 'lib/no_brainer/criteria/where.rb', line 22

def where_present?
  finalized_criteria.options[:where_ast].try(:clauses).present?
end

#without_distinct(value = true) ⇒ Object



39
40
41
42
# File 'lib/no_brainer/criteria/where.rb', line 39

def without_distinct(value = true)
  # helper for delete_all which can't operate on distinct
  chain(:without_distinct => value)
end