Sha256: 8792c0f7eb73187264c5dd6f8776f5a6106f5625eeaaa01e403892c3824f69d3

Contents?: true

Size: 580 Bytes

Versions: 8

Compression:

Stored size: 580 Bytes

Contents

# encoding: utf-8

require 'github_api/core_ext/hash'

module Github
  class ApiFactory

    # Instantiates a new github api object
    def self.new(klass, options={})
      return _create_instance(klass, options) if klass
      raise ArgumentError, 'must provied klass to be instantiated'
    end

  private

    # Passes configuration options to instantiated class
    def self._create_instance(klass, options)
      options.symbolize_keys!
      instance = Github.const_get(klass.to_sym).new options
      Github.api_client = instance
      instance
    end
  end
end # Github

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
github_api-0.4.11 lib/github_api/api_factory.rb
github_api-0.4.10 lib/github_api/api_factory.rb
github_api-0.4.9 lib/github_api/api_factory.rb
github_api-0.4.8 lib/github_api/api_factory.rb
github_api-0.4.7 lib/github_api/api_factory.rb
github_api-0.4.6 lib/github_api/api_factory.rb
github_api-0.4.5 lib/github_api/api_factory.rb
github_api-0.4.4 lib/github_api/api_factory.rb