Sha256: be899608fe3274cc1a2b58a239077140b769b1697a97d1aa0faba147d7ee24ed

Contents?: true

Size: 948 Bytes

Versions: 19

Compression:

Stored size: 948 Bytes

Contents

module UniverseCompiler
  module Entity

    module TypeManagement

      module ClassMethods

        def entity_type(value = nil)
          if value.nil?
            @entity_type || name.underscore
          else
            self.entity_type = value
          end
        end

        def entity_type=(value)
          raise UniverseCompiler::Error, "You cannot change an entity type for class '#{self.name}'" unless @entity_type.nil?
          raise UniverseCompiler::Error, 'Only Symbol is supported for entity_type !' unless value.is_a? Symbol
          @entity_type = value
        end

      end

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

      def type
        self.class.entity_type
      end

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

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

    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
universe_compiler-0.3.12 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.11 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.10 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.9 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.8 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.7 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.6 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.5 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.4 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.3 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.2 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.1 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.3.0 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.2.16 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.2.15 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.2.14 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.2.13 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.2.12 lib/universe_compiler/entity/type_management.rb
universe_compiler-0.2.11 lib/universe_compiler/entity/type_management.rb