Sha256: 92cdbce8fe18e97afc355e6049bf6fdb97720c89d08128e019d476e9de29dbc0

Contents?: true

Size: 760 Bytes

Versions: 3

Compression:

Stored size: 760 Bytes

Contents

# frozen_string_literal: true

require 'http'

module Ebay
  # Adds an HTTP client and ability to switch to the eBay Sandbox environment
  module Requestable
    class << self
      private

      def included(base)
        class << base
          attr_accessor :endpoint
        end
      end
    end

    # @return [HTTP::Client]
    attr_writer :http

    # @!attribute [r] http
    # @return [HTTP::Client]
    def http
      @http ||= HTTP::Client.new
    end

    # @!attribute [r] endpoint
    # @return [String]
    def endpoint
      @endpoint ||= self.class.endpoint
    end

    # Switches to the eBay Sandbox environment
    #
    # @return [self]
    def sandbox
      @endpoint = endpoint.sub('ebay', 'sandbox.ebay')
      self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ebay-ruby-0.3.3 lib/ebay/requestable.rb
ebay-ruby-0.3.2 lib/ebay/requestable.rb
ebay-ruby-0.3.1 lib/ebay/requestable.rb