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



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

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



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

def on_failure(&block)
  @on_failure ||= []
  @on_failure << block if block_given?
  @on_failure
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



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

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