Module: Forecast::Adapter

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



17
18
19
# File 'lib/forecast/adapter.rb', line 17

def self.included(base)
  base.extend(ClassMethods)
end

.instanceObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/forecast/adapter.rb', line 21

def self.instance
  provider = Forecast.config.provider
  if provider.is_a?(Hash)
    adapter_name = provider['adapter'].to_s
    options = provider.clone
    options.delete('adapter')
  else
    adapter_name = provider
    options = {}
  end
  if adapter_name
    adapter_classname = (adapter_name.to_s << "_adapter").split('_').collect!{ |w| w.capitalize }.join
    adapter_class = Object.const_get('Forecast').const_get("Adapters").const_get(adapter_classname)
    adapter_class.new(options)
  else 
    puts 'no adapter provided'
  end
end

Instance Method Details

#configObject



48
49
50
# File 'lib/forecast/adapter.rb', line 48

def config
  Forecast.config.adapters[self.class.slug] || {}
end

#initialize(options = {}) ⇒ Object



40
41
42
# File 'lib/forecast/adapter.rb', line 40

def initialize(options = {})
  @options = options
end

#optionsObject



44
45
46
# File 'lib/forecast/adapter.rb', line 44

def options
  @options
end