Sha256: 77f467c7473a6be75a8a51eb6c0e0c592fe6a25899a78e445e80a7eea21853d3

Contents?: true

Size: 797 Bytes

Versions: 5

Compression:

Stored size: 797 Bytes

Contents

class Evil::Client
  # Carries a final schema for a single operation along with shared connection,
  # and uses it to send requests to the server
  class Operation
    require_relative "operation/request"
    require_relative "operation/response"

    extend Dry::Initializer::Mixin
    param :schema
    param :connection

    # Builds and sends a request and returns a response proccessed by schema
    #
    # @param  [IO, nil] file
    # @param  [Hash<Symbol, Object>] options
    # @return [Object]
    #
    def call(**options)
      req   = request.build(options)
      array = connection.call(req)
      response.handle(array)
    end

    private

    def request
      @request ||= Request.new(schema)
    end

    def response
      @response ||= Response.new(schema)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
evil-client-0.3.1 lib/evil/client/operation.rb
evil-client-0.3.0 lib/evil/client/operation.rb
evil-client-0.2.3 lib/evil/client/operation.rb
evil-client-0.2.2 lib/evil/client/operation.rb
evil-client-0.2.1 lib/evil/client/operation.rb