Class: CloudConfig::ProviderConfig
- Inherits:
-
Object
- Object
- CloudConfig::ProviderConfig
- Defined in:
- lib/cloud-config/provider_config.rb
Overview
A class for storing provider configuration. Use this class to create a new provider and set the provider parameters.
Instance Attribute Summary collapse
-
#provider_name ⇒ Object
readonly
Returns the value of attribute provider_name.
-
#provider_options ⇒ Object
readonly
Returns the value of attribute provider_options.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize(provider_name, provider_options) ⇒ ProviderConfig
constructor
Create a new instance of ProviderConfig.
-
#provider ⇒ Object
Return an instance of the configured provider.
-
#provider_class ⇒ Object
Return the class of the configured provider.
-
#setting(setting_name, setting_options = {}) ⇒ Object
Store the name of a key with this provider.
Constructor Details
#initialize(provider_name, provider_options) ⇒ ProviderConfig
Create a new instance of CloudConfig::ProviderConfig.
15 16 17 18 19 |
# File 'lib/cloud-config/provider_config.rb', line 15 def initialize(provider_name, ) @provider_name = provider_name @provider_options = ProviderOptions.new() @settings = {} end |
Instance Attribute Details
#provider_name ⇒ Object (readonly)
Returns the value of attribute provider_name.
9 10 11 |
# File 'lib/cloud-config/provider_config.rb', line 9 def provider_name @provider_name end |
#provider_options ⇒ Object (readonly)
Returns the value of attribute provider_options.
9 10 11 |
# File 'lib/cloud-config/provider_config.rb', line 9 def @provider_options end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
9 10 11 |
# File 'lib/cloud-config/provider_config.rb', line 9 def settings @settings end |
Instance Method Details
#provider ⇒ Object
Return an instance of the configured provider.
33 34 35 |
# File 'lib/cloud-config/provider_config.rb', line 33 def provider @provider ||= provider_class.new(.to_h) end |
#provider_class ⇒ Object
Return the class of the configured provider.
40 41 42 43 44 45 46 |
# File 'lib/cloud-config/provider_config.rb', line 40 def provider_class @provider_class ||= if .klass generate_class(.klass) else provider_class_from_name(provider_name) end end |
#setting(setting_name, setting_options = {}) ⇒ Object
Store the name of a key with this provider. Provider additional options such as caching.
25 26 27 28 |
# File 'lib/cloud-config/provider_config.rb', line 25 def setting(setting_name, = {}) = () @settings[setting_name] = end |