Class: Memoir::Client
- Inherits:
-
Object
- Object
- Memoir::Client
- Defined in:
- lib/memoir/client.rb
Constant Summary collapse
- API_QUERY_URL =
'/api/query'.freeze
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#host ⇒ Object
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#port ⇒ Object
Returns the value of attribute port.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #dry_run(request) ⇒ Object
-
#initialize(host, port, logger = nil, options = {}) ⇒ Client
constructor
A new instance of Client.
- #run(request) ⇒ Object
Constructor Details
#initialize(host, port, logger = nil, options = {}) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 12 |
# File 'lib/memoir/client.rb', line 6 def initialize(host, port, logger = nil, = {}) @host = host @port = port @timeout = [:timeout] || 10 @logger = logger prepare_connection end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
2 3 4 |
# File 'lib/memoir/client.rb', line 2 def connection @connection end |
#host ⇒ Object
Returns the value of attribute host.
2 3 4 |
# File 'lib/memoir/client.rb', line 2 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
2 3 4 |
# File 'lib/memoir/client.rb', line 2 def logger @logger end |
#port ⇒ Object
Returns the value of attribute port.
2 3 4 |
# File 'lib/memoir/client.rb', line 2 def port @port end |
#timeout ⇒ Object
Returns the value of attribute timeout.
2 3 4 |
# File 'lib/memoir/client.rb', line 2 def timeout @timeout end |
Instance Method Details
#dry_run(request) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/memoir/client.rb', line 32 def dry_run(request) if logger logger.info request.to_json else puts request.to_json end end |
#run(request) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/memoir/client.rb', line 24 def run(request) response = connection.post API_QUERY_URL, request.to_h do |req| req.params['arrays'] = true if request.arrays end Memoir::Response.new response end |