Class: MQ::FilterDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/mq/query.rb

Overview

DSL context for building filter expressions inside select/map blocks.

All methods return a Filter that can be combined with & and |.

Examples:

String matching

MQ::Query.h2.select { contains("Feature") & starts_with("##") }

Comparison

MQ::Query.list.select { gt(5) }

Negation

MQ::Query.select { negate(contains("draft")) }

Instance Method Summary collapse

Instance Method Details

#add(other) ⇒ Object



580
# File 'lib/mq/query.rb', line 580

def add(other) = Filter.new("add(#{other.inspect})")

#contains(text) ⇒ Object

String matching



551
# File 'lib/mq/query.rb', line 551

def contains(text)    = Filter.new("contains(#{text.inspect})")

#emptyObject



578
# File 'lib/mq/query.rb', line 578

def empty          = Filter.new("is_empty()")

#ends_with(text) ⇒ Object



553
# File 'lib/mq/query.rb', line 553

def ends_with(text)   = Filter.new("ends_with(#{text.inspect})")

#eq(value) ⇒ Object

Comparison operators These compare the current pipeline value against the given argument.



562
# File 'lib/mq/query.rb', line 562

def eq(value)  = Filter.new("eq(#{value.inspect})")

#gt(value) ⇒ Object



564
# File 'lib/mq/query.rb', line 564

def gt(value)  = Filter.new("gt(#{value.inspect})")

#gte(value) ⇒ Object



565
# File 'lib/mq/query.rb', line 565

def gte(value) = Filter.new("gte(#{value.inspect})")

#is_mdxObject

Type checks



570
# File 'lib/mq/query.rb', line 570

def is_mdx  = Filter.new("is_mdx()")

#is_nanObject



572
# File 'lib/mq/query.rb', line 572

def is_nan  = Filter.new("is_nan()")

#is_noneObject



571
# File 'lib/mq/query.rb', line 571

def is_none = Filter.new("is_none()")

#is_not_regex_match(pattern) ⇒ Object



558
# File 'lib/mq/query.rb', line 558

def is_not_regex_match(pattern) = Filter.new("is_not_regex_match(#{pattern.inspect})")

#is_regex_match(pattern) ⇒ Object

Regex matching



557
# File 'lib/mq/query.rb', line 557

def is_regex_match(pattern)     = Filter.new("is_regex_match(#{pattern.inspect})")

#lengthObject

String transforms usable in filter context



576
# File 'lib/mq/query.rb', line 576

def length         = Filter.new("len()")

#lt(value) ⇒ Object



566
# File 'lib/mq/query.rb', line 566

def lt(value)  = Filter.new("lt(#{value.inspect})")

#lte(value) ⇒ Object



567
# File 'lib/mq/query.rb', line 567

def lte(value) = Filter.new("lte(#{value.inspect})")

#ne(value) ⇒ Object



563
# File 'lib/mq/query.rb', line 563

def ne(value)  = Filter.new("ne(#{value.inspect})")

#negate(filter) ⇒ Object

Negate a filter expression with not(). Use negate instead of not since not is a Ruby keyword.

Examples:

MQ::Query.select { negate(contains("draft")) }
# => 'select(not(contains("draft")))'


588
# File 'lib/mq/query.rb', line 588

def negate(filter) = Filter.new("not(#{filter})")

#starts_with(text) ⇒ Object



552
# File 'lib/mq/query.rb', line 552

def starts_with(text) = Filter.new("starts_with(#{text.inspect})")

#test(pattern) ⇒ Object



554
# File 'lib/mq/query.rb', line 554

def test(pattern)     = Filter.new("test(#{pattern.inspect})")

#trimObject



577
# File 'lib/mq/query.rb', line 577

def trim           = Filter.new("trim()")

#typeObject



573
# File 'lib/mq/query.rb', line 573

def type    = Filter.new("type")