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_ID =
Default Region
'regionOne'
- SSL_VERIFY_MODE =
Default when uri.scheme is https
true
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Attributes.
-
#log ⇒ Object
readonly
Attributes.
-
#services ⇒ Object
readonly
Attributes.
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.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/misty/config.rb', line 38 def initialize(arg) raise CredentialsError if arg.nil? || arg.empty? || arg[:auth].nil? || arg[:auth].empty? @auth = Misty::Auth.build(arg[:auth]) # TODO: pass @log @log = set_log(arg[:log_file], arg[:log_level]) @globals = set_config(arg) @services = {} # TODO: Adjust Services to use enumerable arg.each do |e, k| Misty::SERVICES.each do |serv| @services[e] = k if serv[:name] == e end end end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Attributes
-
arg
-Hash
of configuration options
36 37 38 |
# File 'lib/misty/config.rb', line 36 def auth @auth end |
#log ⇒ Object (readonly)
Attributes
-
arg
-Hash
of configuration options
36 37 38 |
# File 'lib/misty/config.rb', line 36 def log @log end |
#services ⇒ Object (readonly)
Attributes
-
arg
-Hash
of configuration options
36 37 38 |
# File 'lib/misty/config.rb', line 36 def services @services end |
Instance Method Details
#get_service(method) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/misty/config.rb', line 52 def get_service(method) set = {} set[:auth] = @auth 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
66 67 68 69 70 71 72 73 |
# File 'lib/misty/config.rb', line 66 def set_service(arg) set = {} set[:base_path] = arg[:base_path] ? arg[:base_path] : nil set[:base_url] = arg[:base_url] ? arg[:base_url] : nil set[:version] = arg[:version] ? arg[:version] : nil set[:api_version] = arg[:api_version] ? arg[:api_version] : nil set end |