Class: Oso::Polar::Query

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/oso/polar/query.rb

Overview

A single Polar query.

Instance Method Summary collapse

Constructor Details

#initialize(ffi_query, host:, bindings: {}) ⇒ Query

Returns a new instance of Query.

Parameters:



13
14
15
16
17
18
19
# File 'lib/oso/polar/query.rb', line 13

def initialize(ffi_query, host:, bindings: {})
  @calls = {}
  @ffi_query = ffi_query
  ffi_query.enrich_message = host.method(:enrich_message)
  @host = host
  bindings.each { |k, v| ffi_query.bind k, host.to_polar(v) }
end

Instance Method Details

#each {|| ... } ⇒ Enumerator

Create an enumerator that can be polled to advance the query loop. Yields results one by one.

Yield Parameters:

  • (Hash<String, Object>)

Returns:

  • (Enumerator)

Raises:

  • (Error)

    if any of the FFI calls raise one.



27
28
29
# File 'lib/oso/polar/query.rb', line 27

def each(&block)
  run(&block)
end