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

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) on_subclass (readonly)

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



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

def on_subclass
  @on_subclass
end

- (Object) subclasses (readonly)

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



41
42
43
# File 'lib/sequel/plugins/subclasses.rb', line 41

def subclasses
  @subclasses
end

Instance Method Details

- (Object) descendents

All descendent classes of this model.



44
45
46
# File 'lib/sequel/plugins/subclasses.rb', line 44

def descendents
  Sequel.synchronize{_descendents}
end

- (Object) inherited(subclass)

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



53
54
55
56
57
# File 'lib/sequel/plugins/subclasses.rb', line 53

def inherited(subclass)
  super
  Sequel.synchronize{subclasses << subclass}
  on_subclass.call(subclass) if on_subclass
end