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



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

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

#contains(text) ⇒ Object

String matching



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

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

#emptyObject



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

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

#ends_with(text) ⇒ Object



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

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.



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

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

#gt(value) ⇒ Object



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

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

#gte(value) ⇒ Object



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

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

#is_mdxObject

Type checks



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

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

#is_nanObject



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

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

#is_noneObject



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

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

#is_not_regex_match(pattern) ⇒ Object



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

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

#is_regex_match(pattern) ⇒ Object

Regex matching



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

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

#lengthObject

String transforms usable in filter context



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

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

#lt(value) ⇒ Object



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

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

#lte(value) ⇒ Object



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

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

#ne(value) ⇒ Object



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

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


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

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

#starts_with(text) ⇒ Object



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

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

#test(pattern) ⇒ Object



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

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

#trimObject



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

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

#typeObject



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

def type    = Filter.new("type")