Module: Sequel::Plugins::Subclasses::ClassMethods
- Defined in:
- lib/sequel/plugins/subclasses.rb
Instance Attribute Summary collapse
-
#on_subclass ⇒ Object
readonly
Callable object that should be called with every descendent class created.
-
#subclasses ⇒ Object
readonly
All subclasses for the current model.
Instance Method Summary collapse
-
#descendants ⇒ Object
(also: #descendents)
All descendent classes of this model.
-
#freeze_descendants ⇒ Object
(also: #freeze_descendents)
Freeze all descendent classes.
Instance Attribute Details
#on_subclass ⇒ Object (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 |
#subclasses ⇒ Object (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
#descendants ⇒ Object 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_descendants ⇒ Object 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 |