Sha256: 2a3bda23acbaf07d3719b9cec25732893710d0b4aa2fcc35ab86703c03895bdc

Contents?: true

Size: 864 Bytes

Versions: 2

Compression:

Stored size: 864 Bytes

Contents

require_relative 'connect_client/client'
require_relative 'connect_client/configuration'

module ConnectClient
  class << self

    def configure
      config = Configuration.new
      yield(config)

      @client = ConnectClient::Client.new config
    end

    def reset
      @client = nil
    end

    def method_missing(method, *args, &block)
      return super unless client.respond_to?(method)
      client.send(method, *args, &block)
    end

    def respond_to?(method)
      return (!@client.nil? && @client.respond_to?(method)) || super
    end   

    private

    def client
      raise UnconfiguredError if @client.nil?

      @client
    end 
  end

  class UnconfiguredError < StandardError
    def message
      "Connect must configured before it can be used, please call Connect.configure"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
connect_client-0.1.1 lib/connect_client.rb
connect_client-0.1.0 lib/connect_client.rb