Module: Sidetiq::SubclassTracking

Included in:
Schedulable, Sidetiq::Schedulable::ClassMethods
Defined in:
lib/sidetiq/subclass_tracking.rb

Instance Method Summary collapse

Instance Method Details

#inherited(klass) ⇒ Object


15
16
17
18
# File 'lib/sidetiq/subclass_tracking.rb', line 15

def inherited(klass)
  super
  subclasses << klass
end

#subclasses(deep = false) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
# File 'lib/sidetiq/subclass_tracking.rb', line 3

def subclasses(deep = false)
  @subclasses ||= []

  if deep
    @subclasses.inject([]) do |all, subclass|
      (all << subclass) + subclass.subclasses(true)
    end
  else
    @subclasses
  end
end