Sha256: 515741088f21824fa4df2df8697795224cb7a98d9ceaa3a715c1eee0d30d3830
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
module OpenStax module Exchange @use_real_client = true def self.configure yield configuration end def self.configuration @configuration ||= Configuration.new end def self.reset! @client = nil end def self.use_real_client @use_real_client = true end def self.use_fake_client @use_real_client = false end def self.use_real_client? !!@use_real_client end def self.create_identifiers begin client.create_identifiers rescue StandardError => error raise ClientError.new("create_identifiers failure", error) end end 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 private def self.client begin @client ||= create_client rescue StandardError => error raise ClientError.new("initialization failure", error) end end def self.create_client if use_real_client? RealClient.new configuration else FakeClient.new configuration end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
openstax_exchange-0.1.0 | lib/openstax/exchange/exchange.rb |