module ErpBaseErpSvcs::Extensions::ActiveRecord::StiInstantiation::ClassMethods
Public Instance Methods
new(*args, &block)
click to toggle source
Calls superclass method
# File lib/erp_base_erp_svcs/extensions/active_record/sti_instantiation.rb, line 21 def new(*args, &block) options = args.first.is_a?(Hash) ? args.first : {} type = options[:type] || options['type'] klass = type.is_a?(Class) ? type : type.constantize if type if type and klass != self raise "STI instantiation error: class #{klass.name} should be a descendant of #{self.name}" unless klass < self klass.new(*args, &block) else super end end