class Tinybucket::ApiFactory

Public Class Methods

create_instance(klass_name) click to toggle source
# File lib/tinybucket/api_factory.rb, line 6
def create_instance(klass_name)
  klass =
    begin
      name = "#{klass_name}Api".intern
      Tinybucket::Api.const_get name
    rescue => e
      # TODO: log exception
      Tinybucket.logger.error e
      raise ArgumentError, 'must provide klass to be instantiated'
    end

  klass.new
end