Module: Discriminable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/discriminable.rb,
lib/discriminable/version.rb
Overview
Source: gist.github.com/rlburkes/798e186acb2f93e787a5
Wouldn’t it be great if you could have STI like functionality without needing to encode strings of class names in the database? Well today is your lucky day! Discriminable Model is here to help.
Simply specify your models desired type column, and provide a block to do the discrimination. If you want the whole STI-esque shebang of properly typed finder methods you can supply an array of ‘discriminate_types’ that will be used to apply an appropriate type.
class Customer < ActiveRecord::Base
include Discriminable
discriminable_by :state
end
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
"3.0.0"