class Bumbleworks::Api::WorkersController

Constants

AllowedCommands

Public Instance Methods

change_global_state() click to toggle source
# File lib/bumbleworks/api/controllers/workers_controller.rb, line 29
def change_global_state
  command = params[:command]
  if AllowedCommands.include?(command.to_s)
    Bumbleworks::Worker.send("#{command}_all")
    render :json => { "status" => "#{command} sent" }
  else
    render :json => { "error" => "not_found" }, :status => 404
  end
end
change_state() click to toggle source
# File lib/bumbleworks/api/controllers/workers_controller.rb, line 18
def change_state
  command = params[:command]
  if AllowedCommands.include?(command.to_s)
    worker_info = Bumbleworks::Worker::Info[params[:id]]
    worker_info.send(command)
    render :json => { "status" => "#{command} sent" }
  else
    render :json => { "error" => "not_found" }, :status => 404
  end
end
index() click to toggle source
# File lib/bumbleworks/api/controllers/workers_controller.rb, line 8
def index
  worker_info = Bumbleworks::Worker::Info.all
  render :json => Bumbleworks::Api::WorkerPresenter.present(worker_info)
end
prune_stale_worker_info() click to toggle source
# File lib/bumbleworks/api/controllers/workers_controller.rb, line 39
def prune_stale_worker_info
  Bumbleworks::Worker::Info.purge_stale_worker_info
  render :json => { "status" => "pruned_stale_worker_info" }
end
show() click to toggle source
# File lib/bumbleworks/api/controllers/workers_controller.rb, line 13
def show
  worker_info = Bumbleworks::Worker::Info[params[:id]]
  render :json => Bumbleworks::Api::WorkerPresenter.present(worker_info)
end

Private Instance Methods

refresh_worker_info() click to toggle source
# File lib/bumbleworks/api/controllers/workers_controller.rb, line 46
def refresh_worker_info
  Bumbleworks::Worker.refresh_worker_info
end