Class: Nis::Client
- Inherits:
-
Object
- Object
- Nis::Client
- Defined in:
- lib/nis/client.rb
Constant Summary collapse
- DEFAULTS =
{ url: -> {ENV['NIS_URL']}, scheme: 'http', host: '127.0.0.1', port: 7890, timeout: 5 }
Instance Attribute Summary collapse
-
#options ⇒ Hash
connection options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#request(method, path, params = nil, &block) ⇒ Hash
Hash converted API Response.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
23 24 25 |
# File 'lib/nis/client.rb', line 23 def initialize( = {}) = () end |
Instance Attribute Details
#options ⇒ Hash
connection options
6 7 8 |
# File 'lib/nis/client.rb', line 6 def end |
Instance Method Details
#request(method, path, params = nil, &block) ⇒ Hash
Returns Hash converted API Response.
31 32 33 34 35 |
# File 'lib/nis/client.rb', line 31 def request(method, path, params = nil, &block) body = connection.send(method, path, params).body hash = parse_body(body) unless body.size == 0 block_given? ? yield(hash) : hash end |