Module: QuasarRestClient

Defined in:
lib/quasar_rest_client.rb,
lib/quasar_rest_client/base.rb,
lib/quasar_rest_client/proxy.rb,
lib/quasar_rest_client/config.rb,
lib/quasar_rest_client/version.rb
more...

Overview

A small library to provide basic interaction with the Quasar Rest API.

Copyright © 2016 Bluewater, LLC.

MIT License

Defined Under Namespace

Classes: Base, Config, Proxy

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.configObject

Access the configuration to set and retrieve information

QuasarRestClient.config.endpoint # => returns value
QuasarRestClient.config.endpoint = 'https://example.com' # => sets endpoint
[View source]

31
32
33
# File 'lib/quasar_rest_client.rb', line 31

def self.config
  return Base.config
end

.configure {|Base.config| ... } ⇒ Object

Provide block-style configuration:

QuasarRestClient.configure do |config|
  config.endpoint = 'http://example.com'
end

Yields:

[View source]

22
23
24
# File 'lib/quasar_rest_client.rb', line 22

def self.configure
  yield Base.config
end

.simple_query(q = '', opts = {}) ⇒ Object

Call Quasar with a simple query

For the last option, :var, the hash keys match the variable name used in the query string. For example, given a query string of:

SELECT * WHERE pop < :cutoff

The var hash should have:

{ cutoff: 100 }

To set the value of the cutoff.

Example:

QuasarRestClient.simple_query(
  'SELECT * WHERE pop < :cutoff',
  {
    limit: 10,
    offset: 20,
    var: {
      cutoff: 100
    }
  }
)

Parameters:

  • q (String) (defaults to: '')

    -- the SQL^2 query string passed in WITHOUT encoding

  • opts (Hash) (defaults to: {})

    -- options to pass along to the Quasar request

  • [Integer] (Hash)

    a customizable set of options

  • [Hash] (Hash)

    a customizable set of options

[View source]

69
70
71
72
# File 'lib/quasar_rest_client.rb', line 69

def self.simple_query(q='', opts={})
  proxy = Proxy.new(q, opts)
  proxy.simple_query
end