Class: Droom::YoutubeController

Inherits:
EngineController show all
Defined in:
app/controllers/droom/youtube_controller.rb

Instance Method Summary collapse

Methods inherited from EngineController

#current_ability

Instance Method Details

#indexObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/droom/youtube_controller.rb', line 12

def index
  fragment = params[:term]
  max = params[:limit] || 10
  @suggestions = []
  unless fragment.blank?
    videos = Droom.yt_client.videos_by(:query => fragment, :per_page => max).videos.to_a
    @suggestions = videos.map { |vid|
      vid.as_json.slice('unique_id', 'title', 'description', 'thumbnails').merge({"type" => "video"})
    }
  end
  respond_with @suggestions
end

#showObject



7
8
9
10
# File 'app/controllers/droom/youtube_controller.rb', line 7

def show
  @video = Droom.yt_client.video_by(params[:yt_id])
  respond_with @video
end