Class: Rackspace::Base
- Inherits:
-
Object
- Object
- Rackspace::Base
- Defined in:
- lib/rackspace/base.rb
Constant Summary collapse
- DEFAULT_CREDENTIALS =
'rackspace_credentials.yml'
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
-
#initialize(params) ⇒ Base
constructor
A new instance of Base.
- #log(msg) ⇒ Object
- #server_api ⇒ Object
- #storage_api ⇒ Object
Constructor Details
#initialize(params) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 14 15 |
# File 'lib/rackspace/base.rb', line 7 def initialize(params) @logger = params.fetch(:logger, Rackspace::Logger.new) @account = params.fetch(:account) @region = params.fetch(:region, DEFAULT_REGION) @credentials = params.fetch(:credentials) { credentials_file = params.fetch(:credentials_file, DEFAULT_CREDENTIALS) YAML.load(File.read(credentials_file)) } end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
3 4 5 |
# File 'lib/rackspace/base.rb', line 3 def account @account end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
3 4 5 |
# File 'lib/rackspace/base.rb', line 3 def credentials @credentials end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/rackspace/base.rb', line 3 def logger @logger end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
3 4 5 |
# File 'lib/rackspace/base.rb', line 3 def region @region end |
Instance Method Details
#log(msg) ⇒ Object
17 18 19 |
# File 'lib/rackspace/base.rb', line 17 def log(msg) logger.log(msg) end |
#server_api ⇒ Object
21 22 23 |
# File 'lib/rackspace/base.rb', line 21 def server_api @server_api ||= ServerApi.new(rackspace_credentials) end |
#storage_api ⇒ Object
25 26 27 |
# File 'lib/rackspace/base.rb', line 25 def storage_api @storage_api ||= StorageApi.new(rackspace_credentials) end |