Module: Ardm::Ar::Inheritance::ClassMethods
- Defined in:
- lib/ardm/ar/inheritance.rb
Instance Method Summary collapse
Instance Method Details
#new(attrs = {}, *a, &b) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ardm/ar/inheritance.rb', line 19 def new(attrs={}, *a, &b) type = attrs && attrs.stringify_keys[inheritance_column.to_s] if type && type != name && type != self #puts "STI found for #{type} #{self}" con = type.is_a?(Class) ? type : type.constantize if con < self con.new(attrs, *a, &b) else raise "Tried to create subclass from #{type} (from key #{inheritance_column}) that is not a subclass of #{name}." end else #puts "No STI found for #{self} (#{attrs.inspect})" super end end |