Sha256: e50317ad05a79e2975d5fc7dd0452cb550bea41456b5c3d8cd417842b64ffc1c

Contents?: true

Size: 720 Bytes

Versions: 2

Compression:

Stored size: 720 Bytes

Contents

module MeducationSDK
  class MeducationSDKError < StandardError
  end
  class MeducationSDKConfigurationError < MeducationSDKError
  end

  class Configuration

    SETTINGS = [
      :logger, :access_id, :secret_key, :endpoint
    ]

    attr_writer *SETTINGS

    def initialize
      Filum.config do |config|
        config.logfile = "./log/loquor.log"
      end
      logger = Filum.logger
    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-0.2.0 lib/meducation_sdk/configuration.rb
meducation_sdk-0.1.0 lib/meducation_sdk/configuration.rb