Class: Cuprum::Collections::Queries::ParseBlock

Inherits:
Command
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cuprum/collections/queries/parse_block.rb

Overview

Command for parsing a Query#where block into criteria.

Examples:

An Empty Query

command = Cuprum::Collections::Queries::ParseBlock.new
result  = command.call { {} }
result.value #=> []

A Value Query

command = Cuprum::Collections::Queries::ParseBlock.new
result  = command.call do
  {
    author: 'Nnedi Okorafor',
    series: 'Binti',
    genre:  'Africanfuturism'
  }
end
result.value #=>
# [
#   ['author', :eq, 'Nnedi Okorafor'],
#   ['series', :eq, 'Binti'],
#   ['genre',  :eq, 'Africanfuturism']
# ]

A Query With Operators

command = Cuprum::Collections::Queries::ParseBlock.new
result  = command.call do
  {
    author: equal('Nnedi Okorafor'),
    series: not_equal('Binti')
  }
end
result.value #=>
# [
#   ['author', :eq, 'Nnedi Okorafor'],
#   ['series', :ne, 'Binti']
# ]

Defined Under Namespace

Classes: Builder