Module: Card::Query::CardQuery::SpecialAttributes
- Included in:
- Card::Query::CardQuery
- Defined in:
- lib/card/query/card_query/special_attributes.rb
Overview
handle special CQL attributes
Instance Method Summary collapse
- #complete(val) ⇒ Object
- #extension_type(_val) ⇒ Object
- #found_by(val) ⇒ Object
- #junction_complete(val) ⇒ Object
-
#match(val) ⇒ Object
Implements the match attribute that matches always against content and name.
- #name_match(val) ⇒ Object
Instance Method Details
#complete(val) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/card/query/card_query/special_attributes.rb', line 30 def complete val no_plus_card = (val =~ /\+/ ? "" : "and #{table_alias}.right_id is null") # FIXME: -- this should really be more nuanced -- # it breaks down after one plus name_like "#{val}%", no_plus_card end |
#extension_type(_val) ⇒ Object
41 42 43 44 45 |
# File 'lib/card/query/card_query/special_attributes.rb', line 41 def extension_type _val # DEPRECATED LONG AGO!!! Rails.logger.info "using DEPRECATED extension_type in WQL" interpret right_plus: AccountID end |
#found_by(val) ⇒ Object
6 7 8 9 10 |
# File 'lib/card/query/card_query/special_attributes.rb', line 6 def found_by val found_by_cards(val).compact.each do |card| subquery found_by_statement(card).merge(fasten: :direct, context: card.name) end end |
#junction_complete(val) ⇒ Object
37 38 39 |
# File 'lib/card/query/card_query/special_attributes.rb', line 37 def junction_complete val name_like ["#{val}%", "%+#{val}%"] end |
#match(val) ⇒ Object
Implements the match attribute that matches always against content and name. 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"] }
16 17 18 19 20 21 22 23 24 |
# File 'lib/card/query/card_query/special_attributes.rb', line 16 def match val val.gsub!(/[^#{Card::Name::OK4KEY_RE}]+/, " ") return nil if val.strip.empty? val.gsub!("*", '\\\\\\\\*') val_list = val.split(/\s+/).map do |v| name_or_content_match v end add_condition and_join(val_list) end |
#name_match(val) ⇒ Object
26 27 28 |
# File 'lib/card/query/card_query/special_attributes.rb', line 26 def name_match val name_like "%#{val}%" end |