Module: Faraday
- Extended by:
- AutoloadHelper
- Defined in:
- lib/faraday/adapter/net_http_persistent.rb,
lib/faraday.rb,
lib/faraday/error.rb,
lib/faraday/utils.rb,
lib/faraday/adapter.rb,
lib/faraday/builder.rb,
lib/faraday/request.rb,
lib/faraday/response.rb,
lib/faraday/upload_io.rb,
lib/faraday/connection.rb,
lib/faraday/middleware.rb,
lib/faraday/adapter/rack.rb,
lib/faraday/adapter/test.rb,
lib/faraday/adapter/excon.rb,
lib/faraday/request/retry.rb,
lib/faraday/adapter/patron.rb,
lib/faraday/adapter/em_http.rb,
lib/faraday/response/logger.rb,
lib/faraday/adapter/net_http.rb,
lib/faraday/adapter/typhoeus.rb,
lib/faraday/request/multipart.rb,
lib/faraday/request/url_encoded.rb,
lib/faraday/adapter/em_synchrony.rb,
lib/faraday/response/raise_error.rb,
lib/faraday/request/authorization.rb,
lib/faraday/request/basic_authentication.rb,
lib/faraday/request/token_authentication.rb,
lib/faraday/adapter/em_synchrony/parallel_manager.rb
Overview
Rely on autoloading instead of explicit require; helps avoid the “already initialized constant” warning on Ruby 1.8.7 when NetHttp is refereced below. require ‘faraday/adapter/net_http’
Defined Under Namespace
Modules: AutoloadHelper, Error, MiddlewareRegistry, Utils Classes: Adapter, Builder, CompositeReadIO, Connection, Middleware, Request, Response
Constant Summary collapse
- VERSION =
"0.8.9"
- Timer =
Timeout
- UploadIO =
::UploadIO
- Parts =
::Parts
Class Attribute Summary collapse
-
.default_adapter ⇒ Object
Returns the value of attribute default_adapter.
- .default_connection ⇒ Object
-
.lib_path ⇒ Object
Returns the value of attribute lib_path.
-
.root_path ⇒ Object
Returns the value of attribute root_path.
Class Method Summary collapse
- .new(url = nil, options = {}) ⇒ Object
-
.register_middleware(type, mapping = nil) ⇒ Object
Public: register middleware classes under a short name.
- .require_libs(*libs) ⇒ Object (also: require_lib)
Methods included from AutoloadHelper
all_loaded_constants, autoload_all, load_autoloaded_constants
Class Attribute Details
.default_adapter ⇒ Object
Returns the value of attribute default_adapter.
6 7 8 |
# File 'lib/faraday.rb', line 6 def default_adapter @default_adapter end |
.default_connection ⇒ Object
32 33 34 |
# File 'lib/faraday.rb', line 32 def self.default_connection @default_connection ||= Connection.new end |
.lib_path ⇒ Object
Returns the value of attribute lib_path.
5 6 7 |
# File 'lib/faraday.rb', line 5 def lib_path @lib_path end |
.root_path ⇒ Object
Returns the value of attribute root_path.
5 6 7 |
# File 'lib/faraday.rb', line 5 def root_path @root_path end |
Class Method Details
.new(url = nil, options = {}) ⇒ Object
9 10 11 12 |
# File 'lib/faraday.rb', line 9 def new(url = nil, = {}) block = block_given? ? Proc.new : nil Faraday::Connection.new(url, , &block) end |
.register_middleware(type, mapping = nil) ⇒ Object
Public: register middleware classes under a short name.
type - A Symbol specifying the kind of middleware (default: :middleware) mapping - A Hash mapping Symbol keys to classes. Classes can be expressed
as fully qualified constant, or a Proc that will be lazily called
to return the former.
Examples
Faraday.register_middleware :aloha => MyModule::Aloha
Faraday.register_middleware :response, :boom => MyModule::Boom
# shortcuts are now available in Builder:
builder.use :aloha
builder.response :boom
Returns nothing.
114 115 116 117 118 |
# File 'lib/faraday.rb', line 114 def self.register_middleware type, mapping = nil type, mapping = :middleware, type if mapping.nil? component = self.const_get(type.to_s.capitalize) component.register_middleware(mapping) end |
.require_libs(*libs) ⇒ Object Also known as: require_lib
14 15 16 17 18 |
# File 'lib/faraday.rb', line 14 def require_libs(*libs) libs.each do |lib| require "#{lib_path}/#{lib}" end end |