Class: Faraday::Adapter::ActionDispatch
- Inherits:
-
Faraday::Adapter
- Object
- Middleware
- Faraday::Adapter
- Faraday::Adapter::ActionDispatch
- Defined in:
- lib/faraday/adapter/action_dispatch.rb
Constant Summary
Constants inherited from Faraday::Adapter
CONTENT_TYPE, DEFAULT_BOUNDARY, FORM_TYPE, MULTIPART_TYPE
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#create_multipart(env, params, boundary = nil) ⇒ Object
TODO: build in support for multipart streaming if action dispatch supports it.
-
#initialize(app, session) ⇒ ActionDispatch
constructor
Initializes a new middleware instance for each request.
Methods inherited from Faraday::Adapter
#full_path_for, #has_multipart?, #process_body_for_request, #process_to_params
Methods included from Faraday::AutoloadHelper
#all_loaded_constants, #autoload_all, #load_autoloaded_constants, #lookup_module, #register_lookup_modules
Methods inherited from Middleware
loaded?, setup_parallel_manager
Constructor Details
#initialize(app, session) ⇒ ActionDispatch
Initializes a new middleware instance for each request. Instead of initiating an HTTP request with a web server, this adapter calls a Rails 3 app using integration tests.
app - The current Faraday request. session - An ActionDispatch::Integration::Session instance.
Returns nothing.
14 15 16 17 18 |
# File 'lib/faraday/adapter/action_dispatch.rb', line 14 def initialize(app, session) super(app) @session = session @session.reset! end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
4 5 6 |
# File 'lib/faraday/adapter/action_dispatch.rb', line 4 def session @session end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/faraday/adapter/action_dispatch.rb', line 20 def call(env) super full_path = full_path_for(env[:url].path, env[:url].query, env[:url].fragment) @session.__send__(env[:method], full_path, env[:body], env[:request_headers]) resp = @session.response env.update \ :status => resp.status, :response_headers => resp.headers, :body => resp.body @app.call env end |
#create_multipart(env, params, boundary = nil) ⇒ Object
TODO: build in support for multipart streaming if action dispatch supports it.
33 34 35 36 |
# File 'lib/faraday/adapter/action_dispatch.rb', line 33 def create_multipart(env, params, boundary = nil) stream = super stream.read end |