Class: NoBrainer::Criteria::Where::IndexFinder::IndexStrategy

Inherits:
Struct
  • Object
show all
Defined in:
lib/no_brainer/criteria/where.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#criteria_astObject

Returns the value of attribute criteria_ast

Returns:

  • (Object)

    the current value of criteria_ast



375
376
377
# File 'lib/no_brainer/criteria/where.rb', line 375

def criteria_ast
  @criteria_ast
end

#indexObject

Returns the value of attribute index

Returns:

  • (Object)

    the current value of index



375
376
377
# File 'lib/no_brainer/criteria/where.rb', line 375

def index
  @index
end

#index_finderObject

Returns the value of attribute index_finder

Returns:

  • (Object)

    the current value of index_finder



375
376
377
# File 'lib/no_brainer/criteria/where.rb', line 375

def index_finder
  @index_finder
end

#optimized_clausesObject

Returns the value of attribute optimized_clauses

Returns:

  • (Object)

    the current value of optimized_clauses



375
376
377
# File 'lib/no_brainer/criteria/where.rb', line 375

def optimized_clauses
  @optimized_clauses
end

#rql_argsObject

Returns the value of attribute rql_args

Returns:

  • (Object)

    the current value of rql_args



375
376
377
# File 'lib/no_brainer/criteria/where.rb', line 375

def rql_args
  @rql_args
end

#rql_opObject

Returns the value of attribute rql_op

Returns:

  • (Object)

    the current value of rql_op



375
376
377
# File 'lib/no_brainer/criteria/where.rb', line 375

def rql_op
  @rql_op
end

#rql_optionsObject

Returns the value of attribute rql_options

Returns:

  • (Object)

    the current value of rql_options



375
376
377
# File 'lib/no_brainer/criteria/where.rb', line 375

def rql_options
  @rql_options
end

Instance Method Details

#astObject



376
377
378
# File 'lib/no_brainer/criteria/where.rb', line 376

def ast
  MultiOperator.new(criteria_ast.op, criteria_ast.clauses - optimized_clauses)
end

#rql_procObject



380
381
382
383
384
385
386
387
388
389
390
# File 'lib/no_brainer/criteria/where.rb', line 380

def rql_proc
  lambda do |rql|
    return RethinkDB::RQL.new.expr([]) if rql_op == :get_all && rql_args.empty?

    opt = (rql_options || {}).merge(:index => index.aliased_name)
    r = rql.__send__(rql_op, *rql_args, opt)
    r = r.map { |i| i['doc'] } if rql_op == :get_nearest
    r = r.distinct if index.multi && !index_finder.criteria.options[:without_distinct]
    r
  end
end