Class: Shortwave::Provider::BaseProvider
- Inherits:
-
Object
- Object
- Shortwave::Provider::BaseProvider
- Defined in:
- lib/shortwave/providers.rb
Overview
You should generally use an instance of this class provided by a session: session.album
Direct Known Subclasses
AlbumProvider, ArtistProvider, GroupProvider, LocationProvider, PlaylistProvider, TagProvider, TrackProvider, UserProvider, VenueProvider
Instance Method Summary collapse
-
#build(attributes) ⇒ Object
Builds a model object.
-
#initialize(facade) ⇒ BaseProvider
constructor
Creates a provider with a facade.
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 |