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.
Instance Method Summary collapse
- #dry_run(request) ⇒ Object
-
#initialize(host, port, logger = nil) ⇒ Client
constructor
A new instance of Client.
- #run(request) ⇒ Object
Constructor Details
#initialize(host, port, logger = nil) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 |
# File 'lib/memoir/client.rb', line 6 def initialize(host, port, logger = nil) @host = host @port = port @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 |
Instance Method Details
#dry_run(request) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/memoir/client.rb', line 27 def dry_run(request) if logger logger.info request.to_json else puts request.to_json end end |
#run(request) ⇒ Object
23 24 25 |
# File 'lib/memoir/client.rb', line 23 def run(request) Memoir::Response.new(connection.post API_QUERY_URL, request.to_h) end |