Sha256: 2670b7727e39d6a343b165c5ae197260f628ac6bf6f08913d7a24f70abc6b46c
Contents?: true
Size: 989 Bytes
Versions: 1
Compression:
Stored size: 989 Bytes
Contents
require 'ostruct' module KeycloakConnectRuby CONFIG_OPTIONS = [ 'url', 'realm', 'client_id', 'client_secret', 'logger', 'proxy' ] def self.configure options = OpenStruct.new yield options validate_options(options) @configuration ||= options end def self.config @configuration end def self.logger config.logger end def self.validate_options(options) keys = options.each_pair.to_a.map { |p| p[0].to_s } keys.each do |key| unless CONFIG_OPTIONS.include?(key) raise KeycloakConnectRuby::Errors::Configuration::UnknownOptionError, "Unknown option: #{key}. The config options are: #{CONFIG_OPTIONS.join(', ')}" end end missing_options = CONFIG_OPTIONS - keys if missing_options.any? raise KeycloakConnectRuby::Errors::Configuration::MissingOptionsError, "Missing options: #{missing_options.join(', ')}. The config options are: #{CONFIG_OPTIONS.join(', ')}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
keycloak-connect-ruby-1.0.0 | lib/keycloak-connect-ruby/configuration.rb |