Sha256: 2c27a95224c5080d295f8faa7c856138aa3e95ccee2173d9d63261dfc7f43115

Contents?: true

Size: 761 Bytes

Versions: 27

Compression:

Stored size: 761 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

    # Passes configuration options to instantiated class
    def self.create_instance(klass, options)
      options.symbolize_keys!
      instance = convert_to_constant(klass.to_s).new options
      Github.api_client = instance
      instance
    end

    def self.convert_to_constant(classes)
      constant = Github
      classes.split('::').each do |klass|
        constant = constant.const_get klass
      end
      return constant
    end
  end
end # Github

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
github_api-0.8.11 lib/github_api/api_factory.rb
github_api-0.8.10 lib/github_api/api_factory.rb
github_api-0.8.9 lib/github_api/api_factory.rb
github_api-0.8.8 lib/github_api/api_factory.rb
github_api-0.8.7 lib/github_api/api_factory.rb
github_api-0.8.6 lib/github_api/api_factory.rb
github_api-0.8.5 lib/github_api/api_factory.rb
github_api-0.8.4 lib/github_api/api_factory.rb
github_api-0.8.3 lib/github_api/api_factory.rb
github_api-0.8.2 lib/github_api/api_factory.rb
github_api-0.8.1 lib/github_api/api_factory.rb
github_api-0.8.0 lib/github_api/api_factory.rb
github_api-0.7.2 lib/github_api/api_factory.rb
github_api-0.7.1 lib/github_api/api_factory.rb
github_api-0.7.0 lib/github_api/api_factory.rb
github_api-0.6.5 lib/github_api/api_factory.rb
github_api-0.6.4 lib/github_api/api_factory.rb
github_api-0.6.3 lib/github_api/api_factory.rb
github_api-0.6.2 lib/github_api/api_factory.rb
github_api-0.6.1 lib/github_api/api_factory.rb