module Answers

Constants

VERSION

Public Class Methods

client() click to toggle source

initialized client accessible from the Answers singleton

# File lib/answers/client.rb, line 37
def self.client
  if !client?
    raise Answers::Error.new "Answers Platform API not initialized. Call Answers.init."
  end
  
  @@client
end
client?() click to toggle source
# File lib/answers/client.rb, line 21
def self.client?
  return false if (defined?(@@client)).nil?
  return false if @@client.nil?
  
  true
end
init(config = {}) click to toggle source
# File lib/answers/client.rb, line 8
def self.init(config = {})
  # check env vars by default
  defaulted = {
    user_email: ENV['ANSWERS_USER_EMAIL'],
    user_token: ENV['ANSWERS_USER_TOKEN']
  }
  # if credentials are passed, overwrite the defaults
  defaulted.merge!(config)
      
  # instantiate a client
  @@client = Client.new(config)
end
reset!() click to toggle source

erases the current client, if one exists

# File lib/answers/client.rb, line 29
def self.reset!
  return if !client?
  #return if (defined?(@@client)).nil?
  @@client = nil
  return
end