Sha256: 55ccf09fe592b8c9e251765d09a0ff6d632a70b774d2d954d37813eab924bcf8

Contents?: true

Size: 825 Bytes

Versions: 2

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

require 'acfs/request/callbacks'

module Acfs
  # Encapsulate all data required to make up a request to the
  # underlaying http library.
  #
  class Request
    attr_accessor :body, :format
    attr_reader :url, :headers, :params, :data, :method, :operation

    include Request::Callbacks
    def initialize(url, **options, &block)
      @url = URI.parse(url.to_s).tap do |_url|
        @data    = options.delete(:data) || nil
        @format  = options.delete(:format) || :json
        @headers = options.delete(:headers) || {}
        @params  = options.delete(:params) || {}
        @method  = options.delete(:method) || :get
      end.to_s

      @operation = options.delete(:operation) || nil

      on_complete(&block) if block
    end

    def data?
      !data.nil?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acfs-2.0.0 lib/acfs/request.rb
acfs-1.7.0 lib/acfs/request.rb