Permalink
Browse files

refactor recommender class

  • Loading branch information...
mikesea committed Jul 12, 2012
1 parent 3a8dcdf commit 7c66c5e9094b0b39d46513f09f1e7785f55dbf08
Showing with 10 additions and 2 deletions.
  1. +9 −1 app/models/recommender.rb
  2. +1 −1 spec/models/recommender_spec.rb
View
@@ -1,6 +1,14 @@
class Recommender
- def self.recommend_tracks_from_artists(artists=[], client=Nestling.new)
+ class << self
+ attr_accessor :client
+ end
+
+ # Instantiate a client to communicate with Echonest
+ # Nestling is a wrapper gem for Echonest's API
+ @client ||= Nestling.new
+
+ def self.recommend_tracks_from_artists(artists=[])
response = client.playlist.static(
artist: artists,
bucket: "id:rdio-us-streaming",
@@ -22,7 +22,7 @@
end
it "returns a collection of tracks with populated values" do
- rec = Recommender.recommend_tracks_from_artists(artists, client)
+ rec = Recommender.recommend_tracks_from_artists(artists)
rec.each do |track|
track.class.should be Track
track.artist_name.should_not be nil

0 comments on commit 7c66c5e

Please sign in to comment.