Class: Evil::Client

Inherits:
Object
  • Object
show all
Includes:
Chaining
Defined in:
lib/evil/client.rb,
lib/evil/client/model.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/dictionary.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, Dictionary, Formatter, Names, RSpec Classes: Builder, Container, DefinitionError, Model, NameError, Options, Policy, Resolver, ResponseError, Schema, Settings, TypeError, ValidationError

Class Attribute Summary collapse

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

Class Attribute 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)



57
58
59
# File 'lib/evil/client.rb', line 57

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

Instance Attribute Details

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

Initialized root scope container



90
91
92
# File 'lib/evil/client.rb', line 90

def scope
  @scope
end

Class Method Details

.schemaEvil::Client::Schema::Scope

Schema for the root scope of the client



71
72
73
# File 'lib/evil/client.rb', line 71

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

Instance Method Details

#inspectString Also known as: to_s, to_str

Human-readable representation of the client

Returns:

  • (String)


145
146
147
148
# File 'lib/evil/client.rb', line 145

def inspect
  vars = options.map { |k, v| "@#{k}=#{v}" }.join(", ")
  "#<#{self.class}:#{format('0x%014x', object_id)} #{vars}>"
end

#loggerLogger?

Logger for the root scope

Returns:

  • (Logger, nil)

    The logger attached to current settings



96
97
98
# File 'lib/evil/client.rb', line 96

def logger
  @scope.logger
end

#logger=(logger) ⇒ self

Sets logger to the client

Parameters:

  • logger (Logger, nil)

Returns:

  • (self)


105
106
107
# File 'lib/evil/client.rb', line 105

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

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

Operations defined at the root of the client

Returns:

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


113
114
115
# File 'lib/evil/client.rb', line 113

def operations
  @scope.operations
end

#optionsHash<Symbol, Object>

Options assigned to the client

Returns:

  • (Hash<Symbol, Object>)


137
138
139
# File 'lib/evil/client.rb', line 137

def options
  @scope.options
end

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

Subscopes of client root

Returns:

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


121
122
123
# File 'lib/evil/client.rb', line 121

def scopes
  @scope.scopes
end

#settingsEvil::Client::Settings

Settings of the client



129
130
131
# File 'lib/evil/client.rb', line 129

def settings
  @scope.settings
end