Class: Conoha::Config
- Inherits:
-
Object
- Object
- Conoha::Config
- Defined in:
- lib/conoha/config.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#accounts ⇒ Object
readonly
Returns the value of attribute accounts.
-
#authtoken ⇒ Object
Returns the value of attribute authtoken.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
-
#tenant_id ⇒ Object
readonly
Returns the value of attribute tenant_id.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
Instance Attribute Details
#accounts ⇒ Object (readonly)
Returns the value of attribute accounts.
5 6 7 |
# File 'lib/conoha/config.rb', line 5 def accounts @accounts end |
#authtoken ⇒ Object
Returns the value of attribute authtoken.
5 6 7 |
# File 'lib/conoha/config.rb', line 5 def authtoken @authtoken end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
5 6 7 |
# File 'lib/conoha/config.rb', line 5 def password @password end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
5 6 7 |
# File 'lib/conoha/config.rb', line 5 def public_key @public_key end |
#tenant_id ⇒ Object (readonly)
Returns the value of attribute tenant_id.
5 6 7 |
# File 'lib/conoha/config.rb', line 5 def tenant_id @tenant_id end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
5 6 7 |
# File 'lib/conoha/config.rb', line 5 def username @username end |
Instance Method Details
#load_from_json!(json_str) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/conoha/config.rb', line 34 def load_from_json!(json_str) parsed = JSON.parse json_str raise Error.new unless parsed.is_a? Hash @username = parsed["username"] @password = parsed["password"] @tenant_id = parsed["tenant_id"] @public_key = parsed["public_key"] @authtoken = parsed["authtoken"] @accounts = parsed["accounts"]&.map { |e| Account.new e } end |
#load_from_yaml!(yaml_str) ⇒ Object
29 30 31 32 |
# File 'lib/conoha/config.rb', line 29 def load_from_yaml!(yaml_str) loaded = YAML.load yaml_str raise Error.new unless loaded.is_a? Hash end |