Module | Sequel::Plugins::SingleTableInheritance::ClassMethods |
In: |
lib/sequel/plugins/single_table_inheritance.rb
|
sti_dataset | [R] | The base dataset for STI, to which filters are added to get only the models for the specific STI subclass. |
sti_key | [R] | The column name holding the STI key for this model |
Copy the sti_key and sti_dataset to the subclasses, and filter the subclass‘s dataset so it is restricted to rows where the key column matches the subclass‘s name.
# File lib/sequel/plugins/single_table_inheritance.rb, line 41 41: def inherited(subclass) 42: super 43: sk = sti_key 44: sd = sti_dataset 45: subclass.set_dataset(sd.filter(sk=>subclass.name.to_s), :inherited=>true) 46: subclass.instance_eval do 47: @sti_key = sk 48: @sti_dataset = sd 49: @simple_table = nil 50: end 51: end