Sha256: f9ef7b62f4f19e87073a268249ede809c312a4d7f5ad35f775c1e557c72c9e43

Contents?: true

Size: 617 Bytes

Versions: 8

Compression:

Stored size: 617 Bytes

Contents

require 'mime/types'

module Typhoeus
  class Form
    attr_accessor :params
    attr_reader :traversal

    def initialize(params = {})
      @params = params
    end

    def traversal
      @traversal ||= Typhoeus::Utils.traverse_params_hash(params)
    end

    def process!
      # add params
      traversal[:params].each { |p| formadd_param(p[0], p[1]) }

      # add files
      traversal[:files].each { |file_args| formadd_file(*file_args) }
    end

    def multipart?
      !traversal[:files].empty?
    end

    def to_s
      Typhoeus::Utils.traversal_to_param_string(traversal, false)
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
marnen-typhoeus-0.3.7 lib/typhoeus/form.rb
marnen-typhoeus-0.3.6 lib/typhoeus/form.rb
marnen-typhoeus-0.3.5 lib/typhoeus/form.rb
marnen-typhoeus-0.3.4 lib/typhoeus/form.rb
typhoeus-0.3.3 lib/typhoeus/form.rb
typhoeus-0.3.2 lib/typhoeus/form.rb
xenda-typhoeus-0.2.4 lib/typhoeus/form.rb
typhoeus-0.2.4 lib/typhoeus/form.rb