Module: CQL::Queriable

Included in:
Repository, CukeModeler::Model
Defined in:
lib/cql/queriable.rb

Overview

A mix-in module containing methods used by objects that want to be able to run queries against objects (often themselves).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#query_rootObject

The object against which the query will be run.



8
9
10
# File 'lib/cql/queriable.rb', line 8

def query_root
  @query_root
end

Instance Method Details

#query(&block) ⇒ Object

Performs a query against the current query_root

Raises:

  • (ArgumentError)


12
13
14
15
16
# File 'lib/cql/queriable.rb', line 12

def query(&block)
  raise(ArgumentError, 'Query cannot be run. No query root has been set.') unless @query_root

  Query.new(@query_root, &block).data
end