Module: UniverseCompiler::Entity::TypeManagement

Included in:
Base
Defined in:
lib/universe_compiler/entity/type_management.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



67
68
69
# File 'lib/universe_compiler/entity/type_management.rb', line 67

def self.extended(base)
  included base.class
end

.included(base) ⇒ Object



63
64
65
# File 'lib/universe_compiler/entity/type_management.rb', line 63

def self.included(base)
  base.extend(ClassMethods)
end

.type_class_mapping(type_or_class) ⇒ Object

** Module methods to be directly used



46
47
48
49
50
51
52
53
# File 'lib/universe_compiler/entity/type_management.rb', line 46

def self.type_class_mapping(type_or_class)
  case type_or_class
  when Symbol, String
    types_classes_mapping[type_or_class.to_sym]
  when Class
    type_or_class
  end
end

.types_classes_mappingObject



55
56
57
# File 'lib/universe_compiler/entity/type_management.rb', line 55

def self.types_classes_mapping
  @types_classes_mapping ||= {}
end

.valid_for_type?(entity) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/universe_compiler/entity/type_management.rb', line 59

def self.valid_for_type?(entity)
  entity.respond_to? :type and entity.class.respond_to? :entity_type
end

Instance Method Details

#typeObject

** The only instance method



74
75
76
# File 'lib/universe_compiler/entity/type_management.rb', line 74

def type
  self.class.entity_type
end