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



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

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

#contains(text) ⇒ Object

String matching



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

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

#emptyObject



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

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

#ends_with(text) ⇒ Object



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

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.



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

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

#gt(value) ⇒ Object



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

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

#gte(value) ⇒ Object



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

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

#is_mdxObject

Type checks



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

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

#is_nanObject



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

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

#is_noneObject



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

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

#is_not_regex_match(pattern) ⇒ Object



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

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

#is_regex_match(pattern) ⇒ Object

Regex matching



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

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

#lengthObject

String transforms usable in filter context



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

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

#lt(value) ⇒ Object



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

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

#lte(value) ⇒ Object



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

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

#ne(value) ⇒ Object



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

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")))'


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

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

#starts_with(text) ⇒ Object



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

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

#test(pattern) ⇒ Object



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

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

#trimObject



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

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

#typeObject



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

def type    = Filter.new("type")