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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#on_subclassObject (readonly)

Callable object that should be called with every descendent class created.



52
53
54
# File 'lib/sequel/plugins/subclasses.rb', line 52

def on_subclass
  @on_subclass
end

#subclassesObject (readonly)

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



58
59
60
# File 'lib/sequel/plugins/subclasses.rb', line 58

def subclasses
  @subclasses
end

Instance Method Details

#descendantsObject Also known as: descendents

All descendent classes of this model.



63
64
65
# File 'lib/sequel/plugins/subclasses.rb', line 63

def descendants
  Sequel.synchronize{subclasses.dup}.map{|x| [x] + x.send(:descendants)}.flatten
end

#freeze_descendantsObject Also known as: freeze_descendents

Freeze all descendent classes. This also finalizes the associations for those classes before freezing.



72
73
74
# File 'lib/sequel/plugins/subclasses.rb', line 72

def freeze_descendants
  descendants.each(&:finalize_associations).each(&:freeze)
end