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
@return [String] The API token for your application
Public Class Methods
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
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
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
The Projector
API Host @return [String]
# File lib/projector/client.rb, line 69 def host @options[:host] end