Class: Evil::Client

Inherits:
Object
  • Object
show all
Includes:
Chaining
Defined in:
lib/evil/client.rb,
lib/evil/client/names.rb,
lib/evil/client/rspec.rb,
lib/evil/client/policy.rb,
lib/evil/client/schema.rb,
lib/evil/client/builder.rb,
lib/evil/client/options.rb,
lib/evil/client/chaining.rb,
lib/evil/client/resolver.rb,
lib/evil/client/settings.rb,
lib/evil/client/container.rb,
lib/evil/client/formatter.rb,
lib/evil/client/connection.rb,
lib/evil/client/resolver/uri.rb,
lib/evil/client/schema/scope.rb,
lib/evil/client/builder/scope.rb,
lib/evil/client/resolver/body.rb,
lib/evil/client/resolver/query.rb,
lib/evil/client/container/scope.rb,
lib/evil/client/resolver/format.rb,
lib/evil/client/resolver/headers.rb,
lib/evil/client/resolver/request.rb,
lib/evil/client/schema/operation.rb,
lib/evil/client/builder/operation.rb,
lib/evil/client/resolver/response.rb,
lib/evil/client/resolver/security.rb,
lib/evil/client/container/operation.rb,
lib/evil/client/resolver/middleware.rb,
lib/evil/client/resolver/http_method.rb,
lib/evil/client/exceptions/name_error.rb,
lib/evil/client/exceptions/type_error.rb,
lib/evil/client/exceptions/response_error.rb,
lib/evil/client/exceptions/definition_error.rb,
lib/evil/client/exceptions/validation_error.rb

Overview

Absctract base class for clients to remote APIs

Defined Under Namespace

Modules: Chaining, Connection, Formatter, Names, RSpec Classes: Builder, Container, DefinitionError, NameError, Options, Policy, Resolver, ResponseError, Schema, Settings, TypeError, ValidationError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Evil::Client::Chaining

Instance Attribute Details

#scopeEvil::Client::Container::Scope (readonly)

Initialized root scope container



92
93
94
# File 'lib/evil/client.rb', line 92

def scope
  @scope
end

Class Method Details

.connection#call

Object used as an HTTP(s) connection to remote API

It is expected to implement the method [#call] which should take one argument for a rack-compatible request environment, and return a rack-compatible response.

By default the connection is set to [Evil::Client::Connection], but it can be redefined for a custom client.

Returns:

  • (#call)

    connection (Evil::Client::Connection)



55
56
57
# File 'lib/evil/client.rb', line 55

def connection
  @connection ||= Evil::Client::Connection
end

.connection=(connection) ⇒ self

Sets a custom connection, or resets it to a default one

Parameters:

  • connection (#call, nil)

Returns:

  • (self)


64
65
66
67
# File 'lib/evil/client.rb', line 64

def connection=(connection)
  @connection = connection
  self
end

.schemaEvil::Client::Schema::Scope

Schema for the root scope of the client



73
74
75
# File 'lib/evil/client.rb', line 73

def schema
  @schema ||= Schema::Scope.new(self)
end

Instance Method Details

#loggerLogger?

Logger for the root scope

Returns:

  • (Logger, nil)

    The logger attached to current settings



98
99
100
# File 'lib/evil/client.rb', line 98

def logger
  @scope.logger
end

#logger=(logger) ⇒ self

Sets logger to the client

Parameters:

  • logger (Logger, nil)

Returns:

  • (self)


107
108
109
110
# File 'lib/evil/client.rb', line 107

def logger=(logger)
  @scope.logger = logger
  self
end

#operationsHash<Symbol, Evil::Client::Container::Operation::Builder>

Operations defined at the root of the client

Returns:

  • (Hash<Symbol, Evil::Client::Container::Operation::Builder>)


116
117
118
# File 'lib/evil/client.rb', line 116

def operations
  @scope.operations
end

#optionsHash<Symbol, Object>

Options assigned to the client

Returns:

  • (Hash<Symbol, Object>)


140
141
142
# File 'lib/evil/client.rb', line 140

def options
  @scope.options
end

#scopesHash<Symbol, Evil::Client::Container::Scope::Builder>

Subscopes of client root

Returns:

  • (Hash<Symbol, Evil::Client::Container::Scope::Builder>)


124
125
126
# File 'lib/evil/client.rb', line 124

def scopes
  @scope.scopes
end

#settingsEvil::Client::Settings

Settings of the client



132
133
134
# File 'lib/evil/client.rb', line 132

def settings
  @scope.settings
end