Sha256: 97811658a997b618160bff3a34d00de70743cb8968a27fa89837102d660b15d9

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

module UniverseCompiler
  module Entity

    class Base

      include UniverseCompiler::Utils::ErrorPropagation
      include UniverseCompiler::Utils::DeepTraverse
      include UniverseCompiler::Entity::TypeManagement
      include UniverseCompiler::Entity::FieldManagement
      extend UniverseCompiler::Entity::AutoNamed
      extend UniverseCompiler::Entity::FieldConstraintManagement
      extend UniverseCompiler::Entity::RelationsManagement
      extend UniverseCompiler::Entity::FieldBinder
      include UniverseCompiler::Entity::Validation
      include UniverseCompiler::Entity::Marshalling
      include UniverseCompiler::Entity::Inheritance
      include UniverseCompiler::Entity::Conversion
      include UniverseCompiler::Entity::Overridden
      include UniverseCompiler::Entity::Persistence

      attr_reader :fields
      attr_accessor :universe

      field :name

      def initialize(fields: {}, universe: nil)
        @fields = fields
        define_known_fields_accessors
        self.universe = universe
        self.fully_resolved = true
        if universe.nil?
          self.name = self.class.get_unique_name if self.class.auto_named_entity_type?
        else
          unless universe.compiled?
            self.name = self.class.get_unique_name if self.class.auto_named_entity_type?
          end
        end
      end

      def [](key)
        fields[key]
      end

      def []=(key, value)
        fields[key] = value
      end

    end

  end
end



















Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
universe_compiler-0.2.14 lib/universe_compiler/entity.rb