Sha256: 197eb9ddd9918656d7ed1ef42cc052f755c47bbec866779e10bd1d2150e85fde
Contents?: true
Size: 754 Bytes
Versions: 22
Compression:
Stored size: 754 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 compute_type_without_fallback(obj_class_name) if obj_class = load_class(obj_class_name) obj_class else raise ObjClassNotFound, obj_class_name end end def special_class?(klass) klass == @base_class || klass == @fallback_class end def obj_class_name_for_type(klass) unless special_class?(klass) klass.name end end private def load_class(obj_class) klass = obj_class.constantize klass if klass < @base_class rescue NameError end end end
Version data entries
22 entries across 22 versions & 1 rubygems
Version | Path |
---|---|
scrivito_sdk-1.12.0.rc2 | app/cms/scrivito/type_computer.rb |
scrivito_sdk-1.12.0.rc1 | app/cms/scrivito/type_computer.rb |