Module: Card::Query::CardQuery::MatchAttributes

Included in:
Card::Query::CardQuery
Defined in:
lib/card/query/card_query/match_attributes.rb

Overview

Implements the match attributes that match always against content and/or name. Currently that’s different from the match operator that can be restricted to names or content. Example: { match: “name or content” } vs. { name: [“match”, “a name”] } TODO: unify handling for both using full text indexing

Instance Method Summary collapse

Instance Method Details

#complete(val) ⇒ Object

match names beginning with term



20
21
22
23
24
25
26
27
28
# File 'lib/card/query/card_query/match_attributes.rb', line 20

def complete val
  val = val.to_name
  if val.junction?
    interpret left: val.left
    interpret right: { complete: val.right } if val.right.present?
  else
    add_condition "#{table_alias}.key LIKE '#{val.to_name.key}%'"
  end
end

#match(val) ⇒ Object

match term anywhere in name or content



11
12
13
14
15
16
17
# File 'lib/card/query/card_query/match_attributes.rb', line 11

def match val
  return unless val.present?
  subconds = %i[name content].map do |field|
    Value.new([:match, val], self).to_sql field
  end
  add_condition or_join(subconds)
end

#name_match(val) ⇒ Object

match term anywhere in name DEPRECATE - move handling to name: [“match”, val]



32
33
34
# File 'lib/card/query/card_query/match_attributes.rb', line 32

def name_match val
  interpret name: [:match, val]
end