Class: Veewee::Providers

Inherits:
Object show all
Defined in:
lib/veewee/providers.rb

Instance Method Summary collapse

Constructor Details

#initialize(env, options = {}) ⇒ Providers

Returns a new instance of Providers


3
4
5
6
7
# File 'lib/veewee/providers.rb', line 3

def initialize(env, options = {})
  @env = env
  @options = options
  @providers = Hash.new
end

Instance Method Details

#[](name) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/veewee/providers.rb', line 9

def [](name)
  return @providers[name] if @providers.has_key?(name)

  begin
    require_path = 'veewee/provider/' + name.to_s.downcase + "/provider"
    require require_path

    provider = Object.const_get("Veewee").const_get("Provider").const_get(name.to_s.capitalize).const_get("Provider").new(name, @options, @env)

    @providers[name] = provider
  rescue ::Veewee::Error => e
    raise
  rescue Error => e
    env.ui.error "Error loading provider with #{name}, #{$!}", :prefix => false
  end

end

#lengthObject


27
28
29
# File 'lib/veewee/providers.rb', line 27

def length
  @providers.length
end