module Augmented::Hashes::Polymorphable
Public Instance Methods
polymorph(type_attribute_name = :type)
click to toggle source
# File lib/augmented/hashes/polymorphable.rb, line 6 def polymorph type_attribute_name = :type type = (type_attribute_name if Class === type_attribute_name) || self[type_attribute_name] || self[type_attribute_name.to_s] raise ArgumentError, 'missing the type required for polymorph' if type.to_s.empty? klass = Class === type ? type : Object.const_get(type.to_s) klass.new self end