Class: AwsKeychain::Keychain
- Inherits:
-
Object
- Object
- AwsKeychain::Keychain
- Defined in:
- lib/keychain.rb
Instance Attribute Summary collapse
-
#keychain ⇒ Object
Returns the value of attribute keychain.
Instance Method Summary collapse
-
#[](key) ⇒ Hash
Array operator override to access keys by their name.
-
#initialize(options = {}) ⇒ Keychain
constructor
Initializes a new keychain from the specified keychain file.
-
#list ⇒ Array
Lists the names of all keys in the keychain.
Constructor Details
#initialize(options = {}) ⇒ Keychain
Initializes a new keychain from the specified keychain file
35 36 37 38 39 40 41 42 43 |
# File 'lib/keychain.rb', line 35 def initialize(={}) unless .has_key?(:keychain_file) || .has_key?(:keychain_data) raise ArgumentError, 'Either a keychain_file or keychain_data is required to create a new keychain class' end @keychain = [:keychain_data] || JSON.parse(IO.read([:keychain_file])) # TODO: Validate that the hash is correct. end |
Instance Attribute Details
#keychain ⇒ Object
Returns the value of attribute keychain.
27 28 29 |
# File 'lib/keychain.rb', line 27 def keychain @keychain end |
Instance Method Details
#[](key) ⇒ Hash
Array operator override to access keys by their name
56 57 58 |
# File 'lib/keychain.rb', line 56 def [](key) @keychain[key] end |
#list ⇒ Array
Lists the names of all keys in the keychain
48 49 50 |
# File 'lib/keychain.rb', line 48 def list @keychain.keys end |