Sha256: 8dd75e098174737172698ce5d9254103592f799130f4914a07e402f1ea74a055
Contents?: true
Size: 1.81 KB
Versions: 20
Compression:
Stored size: 1.81 KB
Contents
module Foobara module Manifest # TODO: override new to return Entity when it's an entity class Type < BaseManifest self.category_symbol = :type class << self def new(root_manifest, path) type = super if self == Type if type.entity? type = Entity.new(type.root_manifest, type.path) elsif type.model? type = Model.new(type.root_manifest, type.path) end end type end end def type_manifest relevant_manifest end def entity? type = base_type while type return true if type.reference.to_sym == :entity type = type.base_type end false end def model? return false if reference == "entity" type = base_type while type return true if type.reference.to_sym == :model type = type.base_type end false end def base_type base_type_symbol = self[:base_type] if base_type_symbol Type.new(root_manifest, [:type, self[:base_type]]) end end def target_class if target_classes.size != 1 # :nocov: raise "Can only use #target_class for types with one target class but #{name} has #{target_classes.size}" # :nocov: end target_classes.first end def types_depended_on @types_depended_on ||= self[:types_depended_on].map do |type_reference| Type.new(root_manifest, [:type, type_reference]) end end def type_name scoped_name end def full_type_name scoped_full_name end def builtin? BuiltinTypes.builtin_reference?(reference) end end end end
Version data entries
20 entries across 20 versions & 1 rubygems