module Sequel::Plugins::Subclasses::ClassMethods
Attributes
on_subclass[R]
Callable object that should be called with every descendent class created.
subclasses[R]
All subclasses for the current model. Does not include the model itself.
Public Instance Methods
descendents()
click to toggle source
All descendent classes of this model.
# File lib/sequel/plugins/subclasses.rb 54 def descendents 55 Sequel.synchronize{subclasses.dup}.map{|x| [x] + x.send(:descendents)}.flatten 56 end
freeze_descendents()
click to toggle source
Freeze all descendent classes. This also finalizes the associations for those classes before freezing.
# File lib/sequel/plugins/subclasses.rb 60 def freeze_descendents 61 descendents.each(&:finalize_associations).each(&:freeze) 62 end
inherited(subclass)
click to toggle source
Add the subclass to this model's current subclasses, and initialize a new subclasses instance variable in the subclass.
Calls superclass method
# File lib/sequel/plugins/subclasses.rb 69 def inherited(subclass) 70 super 71 Sequel.synchronize{subclasses << subclass} 72 on_subclass.call(subclass) if on_subclass 73 end