Skip to content

Commit

Permalink
Add examples showing class inheritance to the inheritance plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Feb 6, 2014
1 parent c477120 commit 21bfe7f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
14 changes: 11 additions & 3 deletions lib/sequel/plugins/class_table_inheritance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@ module Plugins
#
# # Set up class table inheritance in the parent class
# # (Not in the subclasses)
# Employee.plugin :class_table_inheritance
# class Employee < Sequel::Model
# plugin :class_table_inheritance
# end
#
# # Set the +kind+ column to hold the class name, and
# # set the subclass table to map to for each subclass
# # Have subclasses inherit from the appropriate class
# class Staff < Employee; end
# class Manager < Employee; end
# class Executive < Manager; end
#
# # You can also set options when loading the plugin:
# # :kind :: column to hold the class name
# # :table_map :: map of class name symbols to table name symbols
# Employee.plugin :class_table_inheritance, :key=>:kind, :table_map=>{:Staff=>:staff}
module ClassTableInheritance
# The class_table_inheritance plugin requires the lazy_attributes plugin
Expand Down
10 changes: 9 additions & 1 deletion lib/sequel/plugins/single_table_inheritance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ module Plugins
#
# # Use the default of storing the class name in the sti_key
# # column (:kind in this case)
# Employee.plugin :single_table_inheritance, :kind
# class Employee < Sequel::Model
# plugin :single_table_inheritance, :kind
# end
#
# # Have subclasses inherit from the appropriate class
# class Staff < Employee; end
# class Manager < Employee; end
#
# # You can also use many different options to configure the plugin:
#
# # Using integers to store the class type, with a :model_map hash
# # and an sti_key of :type
Expand Down

0 comments on commit 21bfe7f

Please sign in to comment.