From 4b0a71ff51aef0ff3fe4f547e9458f89b5bfb17a Mon Sep 17 00:00:00 2001 From: Tobias Svensson Date: Mon, 11 Mar 2013 12:24:42 +0000 Subject: [PATCH] Add Sidetiq.workers. --- lib/sidetiq.rb | 5 +++++ test/test_sidetiq.rb | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lib/sidetiq.rb b/lib/sidetiq.rb index 8ac0477..17e7db9 100644 --- a/lib/sidetiq.rb +++ b/lib/sidetiq.rb @@ -20,6 +20,11 @@ require 'sidetiq/version' # The Sidetiq namespace. module Sidetiq + # Public: Returns an Array of workers including Sidetiq::Schedulable. + def self.workers + schedules.keys + end + # Public: Returns a Hash of Sidetiq::Schedule instances. def self.schedules Clock.synchronize do diff --git a/test/test_sidetiq.rb b/test/test_sidetiq.rb index 7af572a..009ae9e 100644 --- a/test/test_sidetiq.rb +++ b/test/test_sidetiq.rb @@ -6,5 +6,9 @@ class TestSidetiq < Sidetiq::TestCase assert_equal [ScheduledWorker], Sidetiq.schedules.keys assert_kind_of Sidetiq::Schedule, Sidetiq.schedules[ScheduledWorker] end + + def test_workers + assert_equal [ScheduledWorker], Sidetiq.workers + end end