module BeanstalkApi class JobsController < BeanstalkApi::ApplicationController attr_reader :job before_filter :must_have_job def show render json: { job: format_job(job), statistics: connection.job_stats(params[:id]) } end def destroy connection.delete(params[:id]) render json: { job: "Job '#{params[:id]}' Deleted" } end private def must_have_job @job = pool.peek_job(params[:id]) rescue Beanstalk::NotFoundError render json: { error: "Job '#{params[:id]}' not found" } end end end