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,
lib/quasar_rest_client/mogrify_vars.rb

Overview

Include this module

Defined Under Namespace

Modules: MogrifyVars Classes: Base, Config, Proxy

Constant Summary collapse

VERSION =
"0.2.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


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:



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

def self.configure
  yield Base.config
end

.delete_data(coll = '', opts = {}) ⇒ String

Returns JSON reponse.

Parameters:

  • coll (String) (defaults to: '')
    • collection to delete
  • opts (Hash) (defaults to: {})
    • options

Returns:

  • (String)

    JSON reponse



94
95
96
97
# File 'lib/quasar_rest_client.rb', line 94

def self.delete_data(coll='', opts={})
  proxy = Proxy.new(nil, opts)
  proxy.delete_data(collection: coll)
end

.get_data(coll = '', opts = {}) ⇒ String

Returns JSON reponse.

Parameters:

  • coll (String) (defaults to: '')
    • collection to retrieve
  • opts (Hash) (defaults to: {})
    • options

Returns:

  • (String)

    JSON reponse



86
87
88
89
# File 'lib/quasar_rest_client.rb', line 86

def self.get_data(coll='', opts={})
  proxy = Proxy.new(nil, opts)
  proxy.get_data(collection: coll)
end

.long_query(q = '', dest = '', opts = {}) ⇒ String

Returns JSON reponse.

Parameters:

  • q (String) (defaults to: '')
    • query string
  • dest (String) (defaults to: '')
    • destination collection to create
  • opts (Hash) (defaults to: {})
    • options

Returns:

  • (String)

    JSON reponse



78
79
80
81
# File 'lib/quasar_rest_client.rb', line 78

def self.long_query(q='', dest='', opts={})
  proxy = Proxy.new(q, opts)
  proxy.long_query(destination: dest)
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



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