Module: Typhoeus::Request::Callbacks::Types

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

Overview

:nodoc:

Since:

  • 0.5.0

Instance Method Summary collapse

Instance Method Details

#on_complete(&block) {|Typhoeus::Response| ... } ⇒ Array<Block>

Set on_complete callback.

Examples:

Set on_complete.

request.on_complete { |response| p "yay" }

Parameters:

  • block (Block)

    The block to execute.

Yields:

Returns:

  • (Array<Block>)

    All on_complete blocks.

Since:

  • 0.5.0



39
40
41
42
43
# File 'lib/typhoeus/request/callbacks.rb', line 39

def on_complete(&block)
  @on_complete ||= []
  @on_complete << block if block_given?
  @on_complete
end

#on_failure(&block) {|Typhoeus::Response| ... } ⇒ Array<Block>

Set on_failure callback.

Examples:

Set on_failure.

request.on_failure { |response| p "yay" }

Parameters:

  • block (Block)

    The block to execute.

Yields:

Returns:

  • (Array<Block>)

    All on_failure blocks.

Since:

  • 0.5.0



71
72
73
74
75
# File 'lib/typhoeus/request/callbacks.rb', line 71

def on_failure(&block)
  @on_failure ||= []
  @on_failure << block if block_given?
  @on_failure
end

#on_headers(&block) {|Typhoeus::Response| ... } ⇒ Array<Block>

Set on_headers callback.

Examples:

Set on_headers.

request.on_headers { |response| p "yay" }

Parameters:

  • block (Block)

    The block to execute.

Yields:

Returns:

  • (Array<Block>)

    All on_headers blocks.

Since:

  • 0.5.0



87
88
89
90
91
# File 'lib/typhoeus/request/callbacks.rb', line 87

def on_headers(&block)
  @on_headers ||= []
  @on_headers << block if block_given?
  @on_headers
end

#on_success(&block) {|Typhoeus::Response| ... } ⇒ Array<Block>

Set on_success callback.

Examples:

Set on_success.

request.on_success { |response| p "yay" }

Parameters:

  • block (Block)

    The block to execute.

Yields:

Returns:

  • (Array<Block>)

    All on_success blocks.

Since:

  • 0.5.0



55
56
57
58
59
# File 'lib/typhoeus/request/callbacks.rb', line 55

def on_success(&block)
  @on_success ||= []
  @on_success << block if block_given?
  @on_success
end