Class: Evil::Client::Container::Operation

Inherits:
Evil::Client::Container show all
Defined in:
lib/evil/client/container/operation.rb

Overview

Contains operation schema and settings along with DSL method [#call] to sends a request to API and handle the response.

Instance Attribute Summary

Attributes inherited from Evil::Client::Container

#schema, #settings

Instance Method Summary collapse

Methods inherited from Evil::Client::Container

#client, #logger, #logger=, #name, #options, #to_s

Instance Method Details

#callArray

Executes the operation and returns rack-compatible response

rubocop: disable Metrics/AbcSize

Returns:

  • (Array)


12
13
14
15
16
17
18
19
20
# File 'lib/evil/client/container/operation.rb', line 12

def call
  request    = Resolver::Request.call(schema, settings)
  middleware = Resolver::Middleware.call(schema, settings)
  connection = schema.client.connection
  stack      = middleware.inject(connection) { |app, layer| layer.new app }
  response   = stack.call request

  Resolver::Response.call schema, settings, response
end