Class: Cleversafe::Connection
- Inherits:
-
Object
- Object
- Cleversafe::Connection
- Extended by:
- Forwardable
- Defined in:
- lib/cleversafe/connection.rb
Instance Method Summary collapse
-
#initialize(url, options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #ping ⇒ Object
- #status ⇒ Object
- #vault(name) ⇒ Object
- #vaults ⇒ Object
Constructor Details
#initialize(url, options = {}) ⇒ Connection
Returns a new instance of Connection.
10 11 12 |
# File 'lib/cleversafe/connection.rb', line 10 def initialize(url, = {}) @http = Cleversafe::HttpClient.new(url, ) end |
Instance Method Details
#ping ⇒ Object
14 15 16 17 18 19 |
# File 'lib/cleversafe/connection.rb', line 14 def ping head '/' true rescue Exception false end |
#status ⇒ Object
21 22 23 |
# File 'lib/cleversafe/connection.rb', line 21 def status JSON.parse(get('/').to_s) end |
#vault(name) ⇒ Object
29 30 31 |
# File 'lib/cleversafe/connection.rb', line 29 def vault(name) Cleversafe::Vault.new(self, name) end |
#vaults ⇒ Object
25 26 27 |
# File 'lib/cleversafe/connection.rb', line 25 def vaults status['vaults'].map { |v| v['vault_name'] } end |