Class: Misty::Config
- Inherits:
-
Object
- Object
- Misty::Config
- Defined in:
- lib/misty/config.rb,
lib/misty/errors.rb
Defined Under Namespace
Classes: CredentialsError, InvalidDataError
Constant Summary collapse
- CONTENT_TYPE =
Default REST content type. Use :json or :hash
:hash
- CONTENT_TYPES =
Valid content format
%i{hash json}
- INTERFACE =
Default Interface
'public'
- INTERFACES =
Valid endpoint interfaces
%w(admin public internal)
- LOG_FILE =
Default Log file
'/dev/null'
- LOG_LEVEL =
Default Log level
Logger::INFO
- REGION =
Default Region
'regionOne'
- SSL_VERIFY_MODE =
Default when uri.scheme is https
true
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #get_service(method) ⇒ Object
-
#initialize(arg) ⇒ Config
constructor
A new instance of Config.
- #set_service(arg) ⇒ Object
Constructor Details
#initialize(arg) ⇒ Config
Returns a new instance of Config.
32 33 34 35 36 37 38 39 |
# File 'lib/misty/config.rb', line 32 def initialize(arg) raise CredentialsError if arg.nil? || arg.empty? || arg[:auth].nil? || arg[:auth].empty? @log = set_log(arg[:log_file], arg[:log_level]) @globals = set_config(arg) @services = set_services(arg) arg[:log] = @log @token = Misty::Auth::Token.build(arg[:auth]) end |
Instance Attribute Details
#log ⇒ Object (readonly)
Returns the value of attribute log.
30 31 32 |
# File 'lib/misty/config.rb', line 30 def log @log end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
30 31 32 |
# File 'lib/misty/config.rb', line 30 def services @services end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
30 31 32 |
# File 'lib/misty/config.rb', line 30 def token @token end |
Instance Method Details
#get_service(method) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/misty/config.rb', line 41 def get_service(method) set = {} set[:token] = @token set[:log] = @log service_config = @services.key?(method) ? @services[method] : {} if service_config set[:config] = set_config(service_config, @globals) set[:config].merge!(set_service(service_config)) else set[:config] = @globals end set end |
#set_service(arg) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/misty/config.rb', line 55 def set_service(arg) set = {} set[:api_version] = arg[:api_version] ? arg[:api_version] : nil set[:base_path] = arg[:base_path] ? arg[:base_path].chomp('/') : nil set[:endpoint] = arg[:endpoint] ? arg[:endpoint] : nil set[:service_name] = arg[:service_name] ? arg[:service_name] : nil set[:version] = arg[:version] ? arg[:version] : nil set end |