Module: Sequel::Plugins::Subclasses::ClassMethods

Defined in:
lib/sequel/lib/sequel/plugins/subclasses.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#subclassesObject (readonly)

All subclasses for the current model. Does not include the model itself.


27
28
29
# File 'lib/sequel/lib/sequel/plugins/subclasses.rb', line 27

def subclasses
  @subclasses
end

Instance Method Details

#descendentsObject

All descendent classes of this model.


30
31
32
# File 'lib/sequel/lib/sequel/plugins/subclasses.rb', line 30

def descendents
  subclasses.map{|x| [x] + x.descendents}.flatten
end

#inherited(subclass) ⇒ Object

Add the subclass to this model's current subclasses, and initialize a new subclasses instance variable in the subclass.


37
38
39
40
41
# File 'lib/sequel/lib/sequel/plugins/subclasses.rb', line 37

def inherited(subclass)
  super
  subclasses << subclass
  subclass.instance_variable_set(:@subclasses, [])
end