Module: Typhoeus::Request::Before Private

Included in:
Typhoeus::Request
Defined in:
lib/typhoeus/request/before.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

This module provides a way to hook into before a request runs. This is very powerful and you should be careful because when you accidently return a falsy value the request won’t be executed.

Since:

  • 0.5.0

Instance Method Summary collapse

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Overrride run in order to execute callbacks in Typhoeus.before. Will break and return when a callback returns nil or false. Calls super otherwise.

Examples:

Run the request.

request.run

Since:

  • 0.5.0



19
20
21
22
23
24
25
26
27
# File 'lib/typhoeus/request/before.rb', line 19

def run
  Typhoeus.before.each do |callback|
    value = callback.call(self)
    if value.nil? || value == false || value.is_a?(Response)
      return response
    end
  end
  super
end