Module: Ethon::Easy::Operations

Included in:
Ethon::Easy
Defined in:
lib/ethon/easy/operations.rb

Overview

This module contains the logic to prepare and perform an easy.

Instance Method Summary collapse

Instance Method Details

#cleanupObject

Clean up the easy.

Examples:

Perform clean up.

easy.cleanup

43
44
45
# File 'lib/ethon/easy/operations.rb', line 43

def cleanup
  handle.free
end

#handleFFI::Pointer

Returns a pointer to the curl easy handle.

Examples:

Return the handle.

easy.handle

12
13
14
# File 'lib/ethon/easy/operations.rb', line 12

def handle
  @handle ||= FFI::AutoPointer.new(Curl.easy_init, Curl.method(:easy_cleanup))
end

#handle=(h) ⇒ Object

Sets a pointer to the curl easy handle.


18
19
20
# File 'lib/ethon/easy/operations.rb', line 18

def handle=(h)
  @handle = h
end

#performInteger

Perform the easy request.

Examples:

Perform the request.

easy.perform

28
29
30
31
32
33
34
35
# File 'lib/ethon/easy/operations.rb', line 28

def perform
  @return_code = Curl.easy_perform(handle)
  if Ethon.logger.debug?
    Ethon.logger.debug { "ETHON: performed #{log_inspect}" }
  end
  complete
  @return_code
end

#prepareObject

Deprecated.

It is no longer necessary to call prepare.

Prepare the easy. Options, headers and callbacks were set.

Examples:

Prepare easy.

easy.prepare

54
55
56
57
58
59
60
# File 'lib/ethon/easy/operations.rb', line 54

def prepare
  Ethon.logger.warn(
    "ETHON: It is no longer necessary to call "+
    "Easy#prepare. It's going to be removed "+
    "in future versions."
  )
end