Sha256: e98249079de2114564ff893898650828d47383dd5fe8cf79fdff8456c412b837

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module QTest
  class Client
    include QTest::REST::API

    def initialize(_opts = {})
      define_base_client
      define_base_instance_client
    end

    # Configure the Client.
    #
    # ## Example
    #
    #     client = Client.new.configure do |c|
    #       c.base_uri = 'http//qtest.mycompany.com'
    #     end
    #
    def configure
      yield self
      self
    end

    # Get the base URI registered for the Client.
    #
    # @example
    #
    #     client = Client.new.configure do |c|
    #       c.base_uri = 'http://qtest.mycompany.com'
    #     end
    #
    #     client.base_uri #=> 'http://qtest.mycompany.com'
    #
    # @return [String]
    def base_uri
      self.class.base_uri
    end

    # Set the base URI for the Client.
    #
    # @param uri [String] host/address
    def base_uri=(uri)
      self.class.send(:base_uri, uri)
      @base_uri = uri
    end

    private

    # @api private
    def define_base_client
      this = self
      QTest::Base.send(:define_singleton_method, :client) do
        this
      end
    end

    # @api private
    def define_base_instance_client
      this = self
      QTest::Base.send(:define_method, :client) do
        this
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qtest-ruby-0.1.0 lib/qtest/client.rb