Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow using a custom column value<->class mapping to the single_table…
…_inheritance plugin This allows you to configure the mapping used. The default mapping remains the same, where the column value holds the name of the class as a string. However, you can now provide a mapping that allows you to use integers, non-class name strings, or pretty much anything, to map the column values for strings. The most common customization is probably to use integers, which can be easily done with a hash: Employee.plugin :single_table_inheritance, :type, :model_map=>{1=>:Staff, 2=>:Manager} You can also use a pair of custom procs: Employee.plugin :single_table_inheritance, :type, :model_map=>proc{|v| v.reverse}, :key_map=>proc{|klass| klass.name.reverse} Check the new module RDoc for details.
- Loading branch information
1 parent
aa115b3
commit 799a209
Showing
3 changed files
with
167 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters