Module: Queries::Concerns::Identifiers

Extended by:
ActiveSupport::Concern
Included in:
Query
Defined in:
lib/queries/concerns/identifiers.rb

Overview

Helpers for queries that reference Identifier

Instance Method Summary collapse

Instance Method Details

#autocomplete_identifier_cached_exactObject

Autocomplete for tables referencing identifiers See lib/queries/identifiers/autocomplete for autocomplete for identifiers



48
49
50
# File 'lib/queries/concerns/identifiers.rb', line 48

def autocomplete_identifier_cached_exact
  base_query.joins(:identifiers).where(with_identifier_cached.to_sql)
end

#autocomplete_identifier_cached_likeObject



56
57
58
# File 'lib/queries/concerns/identifiers.rb', line 56

def autocomplete_identifier_cached_like
  base_query.joins(:identifiers).where(with_identifier_cached_wildcarded.to_sql)
end

#autocomplete_identifier_identifier_exactObject



52
53
54
# File 'lib/queries/concerns/identifiers.rb', line 52

def autocomplete_identifier_identifier_exact
  base_query.joins(:identifiers).where(with_identifier_identifier.to_sql)
end

#autocomplete_identifier_matching_cached_anywhereObject



60
61
62
# File 'lib/queries/concerns/identifiers.rb', line 60

def autocomplete_identifier_matching_cached_anywhere
  base_query.joins(:identifiers).where(with_identifier_cached_wildcarded.to_sql)
end

#autocomplete_identifier_matching_cached_fragments_anywhereObject



64
65
66
# File 'lib/queries/concerns/identifiers.rb', line 64

def autocomplete_identifier_matching_cached_fragments_anywhere
  base_query.joins(:identifiers).where(with_identifier_cached_like_fragments.to_sql)
end

#identifier_tableArel::Table

Returns:

  • (Arel::Table)


7
8
9
# File 'lib/queries/concerns/identifiers.rb', line 7

def identifier_table
  ::Identifier.arel_table
end

#with_identifier_cachedArel::Nodes::Equality

Returns:

  • (Arel::Nodes::Equality)


17
18
19
# File 'lib/queries/concerns/identifiers.rb', line 17

def with_identifier_cached
  identifier_table[:cached].eq(query_string)
end

#with_identifier_cached_like_fragmentsArel::Nodes::Grouping

Returns:

  • (Arel::Nodes::Grouping)


38
39
40
41
42
# File 'lib/queries/concerns/identifiers.rb', line 38

def with_identifier_cached_like_fragments
  a = [ start_and_end_wildcard ]
  a = a + wildcard_wrapped_integers
  identifier_table[:cached].matches_any(a)
end

#with_identifier_cached_wildcard_endArel::Nodes::Equality

Returns:

  • (Arel::Nodes::Equality)


26
27
28
# File 'lib/queries/concerns/identifiers.rb', line 26

def with_identifier_cached_wildcard_end
  identifier_table[:cached].matches(end_wildcard)
end

#with_identifier_cached_wildcardedArel::Nodes::Equality

Returns:

  • (Arel::Nodes::Equality)


31
32
33
# File 'lib/queries/concerns/identifiers.rb', line 31

def with_identifier_cached_wildcarded
  identifier_table[:cached].matches(start_and_end_wildcard)
end

#with_identifier_identifierArel::Nodes::Equality

Returns:

  • (Arel::Nodes::Equality)


12
13
14
# File 'lib/queries/concerns/identifiers.rb', line 12

def with_identifier_identifier
  identifier_table[:identifier].eq(query_string)
end

#with_identifier_wildcard_endObject



21
22
23
# File 'lib/queries/concerns/identifiers.rb', line 21

def with_identifier_wildcard_end
  identifier_table[:identifier].matches(end_wildcard)
end