module OpenStax::Exchange

Constants

VERSION

Public Class Methods

configuration() click to toggle source
# File lib/openstax/exchange/exchange.rb, line 10
def self.configuration
  @configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source
# File lib/openstax/exchange/exchange.rb, line 6
def self.configure
  yield configuration
end
create_identifiers() click to toggle source
# File lib/openstax/exchange/exchange.rb, line 30
def self.create_identifiers
  begin
    client.create_identifiers
  rescue StandardError => error
    raise ClientError.new("create_identifiers failure", error)
  end
end
record_grade(*args) click to toggle source
# File lib/openstax/exchange/exchange.rb, line 46
def self.record_grade(*args)
  begin
    client.record_grade(*args)
  rescue StandardError => error
    raise ClientError.new("record_grade failure", error)
  end
end
record_multiple_choice_answer(*args) click to toggle source
# File lib/openstax/exchange/exchange.rb, line 38
def self.record_multiple_choice_answer(*args)
  begin
    client.record_multiple_choice_answer(*args)
  rescue StandardError => error
    raise ClientError.new("record_multiple_choice_answer failure", error)
  end
end
reset!() click to toggle source
# File lib/openstax/exchange/exchange.rb, line 14
def self.reset!
  @client = nil
end
use_fake_client() click to toggle source
# File lib/openstax/exchange/exchange.rb, line 22
def self.use_fake_client
  @use_real_client = false
end
use_real_client() click to toggle source
# File lib/openstax/exchange/exchange.rb, line 18
def self.use_real_client
  @use_real_client = true
end
use_real_client?() click to toggle source
# File lib/openstax/exchange/exchange.rb, line 26
def self.use_real_client?
  !!@use_real_client
end

Private Class Methods

client() click to toggle source
# File lib/openstax/exchange/exchange.rb, line 56
def self.client
  begin
    @client ||= create_client
  rescue StandardError => error
    raise ClientError.new("initialization failure", error)
  end
end
create_client() click to toggle source
# File lib/openstax/exchange/exchange.rb, line 64
def self.create_client
  if use_real_client?
    RealClient.new configuration
  else
    FakeClient.new configuration
  end
end