Module: Faraday
- Defined in:
- lib/faraday.rb,
lib/faraday/error.rb,
lib/faraday/utils.rb,
lib/faraday/adapter.rb,
lib/faraday/options.rb,
lib/faraday/request.rb,
lib/faraday/autoload.rb,
lib/faraday/response.rb,
lib/faraday/upload_io.rb,
lib/faraday/connection.rb,
lib/faraday/middleware.rb,
lib/faraday/parameters.rb,
lib/faraday/adapter/rack.rb,
lib/faraday/adapter/test.rb,
lib/faraday/rack_builder.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/adapter/httpclient.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/instrumentation.rb,
lib/faraday/adapter/net_http_persistent.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, FlatParamsEncoder, MiddlewareRegistry, NestedParamsEncoder, Utils Classes: Adapter, ClientError, CompositeReadIO, Connection, ConnectionFailed, ConnectionOptions, Env, Error, Middleware, MissingDependency, Options, ParsingError, ProxyOptions, RackBuilder, Request, RequestOptions, ResourceNotFound, Response, SSLError, SSLOptions, TimeoutError
Constant Summary collapse
- VERSION =
"0.12.1"
- Timer =
Timeout
- UploadIO =
::UploadIO
- Parts =
::Parts
Class Attribute Summary collapse
-
.default_adapter ⇒ Object
Public: Gets or sets the Symbol key identifying a default Adapter to use for the default Faraday::Connection.
-
.default_connection ⇒ Object
Gets the default connection used for simple scripts.
-
.lib_path ⇒ Object
Public: Gets or sets the path that the Faraday libs are loaded from.
-
.root_path ⇒ Object
Public: Gets or sets the root path that Faraday is being loaded from.
Class Method Summary collapse
- .const_missing(name) ⇒ Object
-
.default_connection_options ⇒ Object
Gets the default connection options used when calling Faraday#new.
-
.default_connection_options=(options) ⇒ Object
Public: Sets the default options used when calling Faraday#new.
-
.new(url = nil, options = nil) ⇒ Object
Public: Initializes a new Faraday::Connection.
-
.require_libs(*libs) ⇒ Object
(also: require_lib)
Internal: Requires internal Faraday libraries.
- .respond_to?(symbol, include_private = false) ⇒ Boolean
Class Attribute Details
.default_adapter ⇒ Object
Public: Gets or sets the Symbol key identifying a default Adapter to use for the default Faraday::Connection.
29 30 31 |
# File 'lib/faraday.rb', line 29 def default_adapter @default_adapter end |
.default_connection ⇒ Object
Gets the default connection used for simple scripts.
Returns a Faraday::Connection, configured with the #default_adapter.
111 112 113 |
# File 'lib/faraday.rb', line 111 def self.default_connection @default_connection ||= Connection.new end |
.lib_path ⇒ Object
Public: Gets or sets the path that the Faraday libs are loaded from.
25 26 27 |
# File 'lib/faraday.rb', line 25 def lib_path @lib_path end |
.root_path ⇒ Object
Public: Gets or sets the root path that Faraday is being loaded from. This is the root from where the libraries are auto-loaded from.
22 23 24 |
# File 'lib/faraday.rb', line 22 def root_path @root_path end |
Class Method Details
.const_missing(name) ⇒ Object
228 229 230 231 232 233 234 235 |
# File 'lib/faraday.rb', line 228 def self.const_missing(name) if name.to_sym == :Builder warn "Faraday::Builder is now Faraday::RackBuilder." const_set name, RackBuilder else super end end |
.default_connection_options ⇒ Object
Gets the default connection options used when calling Faraday#new.
Returns a Faraday::ConnectionOptions.
118 119 120 |
# File 'lib/faraday.rb', line 118 def self. @default_connection_options ||= ConnectionOptions.new end |
.default_connection_options=(options) ⇒ Object
Public: Sets the default options used when calling Faraday#new.
123 124 125 |
# File 'lib/faraday.rb', line 123 def self.() @default_connection_options = ConnectionOptions.from() end |
.new(url = nil, options = nil) ⇒ Object
Public: Initializes a new Faraday::Connection.
url - The optional String base URL to use as a prefix for all
requests. Can also be the options Hash.
options - The optional Hash used to configure this Faraday::Connection.
Any of these values will be set on every request made, unless
overridden for a specific request.
:url - String base URL.
:params - Hash of URI query unencoded key/value pairs.
:headers - Hash of unencoded HTTP header key/value pairs.
:request - Hash of request options.
:ssl - Hash of SSL options.
:proxy - Hash of Proxy options.
Examples
Faraday.new 'http://faraday.com'
# http://faraday.com?page=1
Faraday.new 'http://faraday.com', :params => {:page => 1}
# same
Faraday.new :url => 'http://faraday.com',
:params => {:page => 1}
Returns a Faraday::Connection.
64 65 66 67 68 |
# File 'lib/faraday.rb', line 64 def new(url = nil, = nil) block = block_given? ? Proc.new : nil = ? .merge() : Faraday::Connection.new(url, , &block) end |
.require_libs(*libs) ⇒ Object Also known as: require_lib
Internal: Requires internal Faraday libraries.
*libs - One or more relative String names to Faraday classes.
Returns nothing.
75 76 77 78 79 |
# File 'lib/faraday.rb', line 75 def require_libs(*libs) libs.each do |lib| require "#{lib_path}/#{lib}" end end |
.respond_to?(symbol, include_private = false) ⇒ Boolean
92 93 94 |
# File 'lib/faraday.rb', line 92 def respond_to?(symbol, include_private = false) default_connection.respond_to?(symbol, include_private) || super end |