class Projector::Client

Primary static class for interacting with the Projector API.

The Projector SDK accepts direct configuration or uses environment variables, in support of the {12factor.net/ Twelve Factor Application} pattern. PROJECTOR_API_HOST and PROJECTOR_API_TOKEN variables are used by default.

If you wish to manually configure the client, create an initializer and use the {Projector::Client.configure} block to set properties as needed.

@example Manually configuring the Projector Client

require 'projector'
Projector::Client.configure do |client|
  client[:host] = 'https://api.projector.com'
  client[:token] = '<YOUR-API-TOKEN>'
end

Attributes

token[RW]

@return [String] The API token for your application

Public Class Methods

configure() { |options| ... } click to toggle source

Configure the global Projector client options using a block

@yield [Hash] a hash of configuration values for the Projector Client @return [Hash]

# File lib/projector/client.rb, line 51
def self.configure
  yield options
end
new(options = {}) click to toggle source

Initialize a new client.

@param [Hash] options @option options [String] :token The API access token @option options [String] :host The API host

# File lib/projector/client.rb, line 60
def initialize(options = {})
  options = self.class.options.merge(options)
  @host = options[:host] || ENV['PROJECTOR_API_HOST']
  @token = options[:token] || ENV['PROJECTOR_API_TOKEN']
  @options = options
end
options() click to toggle source

The current configuration parameters for all clients @return [Hash]

# File lib/projector/client.rb, line 33
def self.options
  @options ||= {
    host: ENV['PROJECTOR_API_HOST'] || 'https://api.projector.com'
  }
end
options=(val) click to toggle source

Replaces the global Projector client options

@param [Hash] val the parameters to store @return [Hash]

# File lib/projector/client.rb, line 43
def self.options=(val)
  @options = val
end

Public Instance Methods

host() click to toggle source

The Projector API Host @return [String]

# File lib/projector/client.rb, line 69
def host
  @options[:host]
end