Class: Tinybucket::ApiFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/tinybucket/api_factory.rb

Class Method Summary collapse

Class Method Details

.create_instance(klass_name) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# 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