Sha256: 9da07cab4b13e81719ef743c0c589fc84024bf3641e8f0bf6d0d7e76b8200156
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
module MeducationSDK class MeducationSDKError < StandardError end class MeducationSDKConfigurationError < MeducationSDKError end class Configuration SETTINGS = [ :logger ] attr_writer *SETTINGS def initialize self.logger = Filum.logger Loquor.config do |config| config.endpoint = "http://www.meducation.net/system" config.substitute_values[true] = ":__true__" config.substitute_values[false] = ":__false__" config.retry_404s = true end end [:access_id, :secret_key, :endpoint, :cache].each do |setting| define_method "#{setting}=" do |val| Loquor.config.send("#{setting}=", val) end end def logger=(val) @logger = val Loquor.config.logger = val end SETTINGS.each do |setting| define_method setting do get_or_raise(setting) end end private def get_or_raise(setting) instance_variable_get("@#{setting.to_s}") || raise(MeducationSDKConfigurationError.new("Configuration for #{setting} is not set")) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
meducation_sdk-1.5.7 | lib/meducation_sdk/configuration.rb |
meducation_sdk-1.5.6 | lib/meducation_sdk/configuration.rb |