Class: Queries::DocumentAutocompleteQuery

Inherits:
Query
  • Object
show all
Includes:
Arel::Nodes
Defined in:
lib/queries/document_autocomplete_query.rb

Instance Attribute Summary

Attributes inherited from Query

#dynamic_limit, #project_id, #query_string, #terms

Instance Method Summary (collapse)

Methods inherited from Query

#build_terms, #end_wildcard, #fragments, #identifier_table, #initialize, #integers, #named, #no_digits, #only_ids, #only_integers?, #parent, #parent_child_join, #parent_child_where, #result, #scope, #start_and_end_wildcard, #start_wildcard, #strings, #wildcard_wrapped_integers, #with_id, #with_identifier_like, #with_project_id, #years

Constructor Details

This class inherits a constructor from Queries::Query

Instance Method Details

- (Scope) all

Returns:

  • (Scope)


28
29
30
# File 'lib/queries/document_autocomplete_query.rb', line 28

def all 
  Document.where(where_sql).limit(200).order(:id)
end

- (Object) file_name_like



23
24
25
# File 'lib/queries/document_autocomplete_query.rb', line 23

def file_name_like
  table[:document_file_file_name].matches(end_wildcard)
end

- (Object) or_clauses



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/queries/document_autocomplete_query.rb', line 10

def or_clauses
  clauses = [
    file_name_like,
    with_id
  ].compact

  a = clauses.shift
  clauses.each do |b|
    a = a.or(b)
  end
  a
end

- (Object) table



32
33
34
# File 'lib/queries/document_autocomplete_query.rb', line 32

def table
  Document.arel_table
end

- (Object) where_sql



6
7
8
# File 'lib/queries/document_autocomplete_query.rb', line 6

def where_sql
  or_clauses.to_sql
end