Class: Ethon::Easy::Form Private
- Inherits:
-
Object
- Object
- Ethon::Easy::Form
- Defined in:
- lib/ethon/easy/form.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This class represents a form and is used to send a payload in the request body via POST/PUT. It handles multipart forms, too.
Instance Method Summary collapse
-
#first ⇒ FFI::Pointer
private
Return a pointer to the first form element in libcurl.
-
#initialize(easy, params, multipart = nil) ⇒ Form
constructor
private
Return a new Form.
-
#last ⇒ FFI::Pointer
private
Return a pointer to the last form element in libcurl.
-
#materialize ⇒ Object
private
Add form elements to libcurl.
-
#multipart? ⇒ Boolean
private
Return if form is multipart.
Methods included from Queryable
#build_query_pairs, #empty?, #file_info, included, #query_pairs, #to_s
Methods included from Util
Constructor Details
#initialize(easy, params, multipart = nil) ⇒ Form
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.
Return a new Form.
25 26 27 28 29 |
# File 'lib/ethon/easy/form.rb', line 25 def initialize(easy, params, multipart = nil) @easy = easy @params = params || {} @multipart = multipart end |
Instance Method Details
#first ⇒ FFI::Pointer
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.
Return a pointer to the first form element in libcurl.
37 38 39 |
# File 'lib/ethon/easy/form.rb', line 37 def first @first ||= FFI::MemoryPointer.new(:pointer) end |
#last ⇒ FFI::Pointer
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.
Return a pointer to the last form element in libcurl.
47 48 49 |
# File 'lib/ethon/easy/form.rb', line 47 def last @last ||= FFI::MemoryPointer.new(:pointer) end |
#materialize ⇒ Object
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.
Add form elements to libcurl.
67 68 69 |
# File 'lib/ethon/easy/form.rb', line 67 def materialize query_pairs.each { |pair| form_add(pair.first.to_s, pair.last) } end |
#multipart? ⇒ Boolean
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.
Return if form is multipart. The form is multipart when it contains a file or multipart option is set on the form during creation.
58 59 60 61 |
# File 'lib/ethon/easy/form.rb', line 58 def multipart? return true if @multipart query_pairs.any?{|pair| pair.respond_to?(:last) && pair.last.is_a?(Array)} end |