Class: Shortwave::Provider::BaseProvider

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

Overview

You should generally use an instance of this class provided by a session: session.album

Instance Method Summary collapse

Constructor Details

#initialize(facade) ⇒ BaseProvider

Creates a provider with a facade



36
37
38
39
# File 'lib/shortwave/providers.rb', line 36

def initialize(facade)
  @klass  = Model.const_get(self.class.name.split("::").last.sub("Provider",''))
  @facade = facade
end

Instance Method Details

#build(attributes) ⇒ Object

Builds a model object.



42
43
44
45
46
47
# File 'lib/shortwave/providers.rb', line 42

def build(attributes)
  model = @klass.new
  attributes.each {|attr, value| model.send("#{attr}=".to_sym, value) }
  model.session = @facade.session
  model
end