Sha256: 8bb611d8425be84ea34103f29e64a1de4ced584d175788eb57f4d25787a55bff
Contents?: true
Size: 593 Bytes
Versions: 15
Compression:
Stored size: 593 Bytes
Contents
module Scrivito class TypeComputer def initialize(base_class, fallback_class) @base_class, @fallback_class = base_class, fallback_class end def compute_type(obj_class_name) load_class(obj_class_name) || @fallback_class end def special_class?(klass) klass == @base_class || klass == @fallback_class end private def load_class(obj_class_name) klass = obj_class_name.constantize klass if inherits_from_base?(klass) rescue NameError end def inherits_from_base?(klass) klass.ancestors.include?(@base_class) && klass != @base_class end end end
Version data entries
15 entries across 15 versions & 1 rubygems