--- !ruby/object:RI::ClassDescription 
attributes: []

class_methods: 
- !ruby/object:RI::MethodSummary 
  name: apply
- !ruby/object:RI::MethodSummary 
  name: configure
comment: 
- !ruby/struct:SM::Flow::P 
  body: "The class_table_inheritance plugin allows you to model inheritance in the database using a table per model class in the hierarchy, with only columns unique to that model class (or subclass hierarchy) being stored in the related table. For example, with this hierarchy:"
- !ruby/struct:SM::Flow::VERB 
  body: "                       Employee\n                      /        \\\n                   Staff     Manager\n                                |\n                            Executive\n"
- !ruby/struct:SM::Flow::P 
  body: "the following database schema may be used (table - columns):"
- !ruby/object:SM::Flow::LIST 
  contents: 
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: employees - id, name, kind
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: staff - id, manager_id
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: managers - id, num_staff
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: executives - id, num_managers
  type: :BULLET
- !ruby/struct:SM::Flow::P 
  body: "The class_table_inheritance plugin assumes that the main table (e.g. employees) has a primary key field (usually autoincrementing), and all other tables have a foreign key of the same name that points to the same key in their superclass's table. For example:"
- !ruby/object:SM::Flow::LIST 
  contents: 
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: employees.id - primary key, autoincrementing
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: staff.id - foreign key referencing employees(id)
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: managers.id - foreign key referencing employees(id)
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: executives.id - foreign key referencing managers(id)
  type: :BULLET
- !ruby/struct:SM::Flow::P 
  body: "When using the class_table_inheritance plugin, subclasses use joined datasets:"
- !ruby/struct:SM::Flow::VERB 
  body: "  Employee.dataset.sql  # SELECT * FROM employees\n  Manager.dataset.sql   # SELECT * FROM employees\n                        # INNER JOIN managers USING (id)\n  Executive.dataset.sql # SELECT * FROM employees\n                        # INNER JOIN managers USING (id)\n                        # INNER JOIN executives USING (id)\n"
- !ruby/struct:SM::Flow::P 
  body: This allows Executive.all to return instances with all attributes loaded. The plugin overrides the deleting, inserting, and updating in the model to work with multiple tables, by handling each table individually.
- !ruby/struct:SM::Flow::P 
  body: "This plugin allows the use of a :key option when loading to mark a column holding a class name. This allows methods on the superclass to return instances of specific subclasses. This plugin also requires the lazy_attributes plugin and uses it to return subclass specific attributes that would not be loaded when calling superclass methods (since those wouldn't join to the subclass tables). For example:"
- !ruby/struct:SM::Flow::VERB 
  body: "  a = Employee.all # [&lt;#Staff&gt;, &lt;#Manager&gt;, &lt;#Executive&gt;]\n  a.first.values # {:id=&gt;1, name=&gt;'S', :kind=&gt;'Staff'}\n  a.first.manager_id # Loads the manager_id attribute from the database\n"
constants: []

full_name: Sequel::Plugins::ClassTableInheritance
includes: []

instance_methods: []

name: ClassTableInheritance
superclass: 
