Class: UniverseCompiler::Entity::Base

Inherits:
Object
  • Object
show all
Extended by:
AutoNamed, FieldBinder, FieldConstraintManagement, RelationsManagement
Includes:
Conversion, FieldManagement, Inheritance, Marshalling, Overridden, Persistence, TypeManagement, Validation, Utils::DeepTraverse, Utils::ErrorPropagation
Defined in:
lib/universe_compiler/entity.rb

Direct Known Subclasses

Override

Constant Summary

Constants included from FieldConstraintManagement

FieldConstraintManagement::BOOLEAN_CONSTRAINTS, FieldConstraintManagement::INCOMPATIBLE_CONSTRAINTS, FieldConstraintManagement::PARAMETRIZED_CONSTRAINTS

Instance Attribute Summary collapse

Attributes included from AutoNamed

#auto_named_entity_type_seed

Attributes included from Persistence

#source_uri

Attributes included from Inheritance

#compiled

Instance Method Summary collapse

Methods included from AutoNamed

auto_named_entity_type, auto_named_entity_type?, get_unique_name

Methods included from FieldConstraintManagement

define_constraint, field, fields_constraints

Methods included from RelationsManagement

has_many, has_one

Methods included from FieldBinder

field_accessor, field_reader, field_writer

Methods included from Persistence

#delete, load, #save

Methods included from Overridden

#apply_override, #overridden_by

Methods included from Conversion

#==, #as_path, #encode_with, #eql?, #init_with, #inspect, #to_composite_key, #to_hash, #to_reference, #to_uniq_id

Methods included from Inheritance

#apply_inheritance, #valid_for_inheritance?

Methods included from Marshalling

#dereferenced_fields, #fully_resolved?, #resolve_fields_references, #resolve_fields_references!, #traverse_fields

Methods included from Validation

#invalid_fields, #valid?, #valid_for_fields_constraints?

Methods included from TypeManagement

extended, included, #type, type_class_mapping, types_classes_mapping, valid_for_type?

Methods included from Utils::DeepTraverse

#deep_map, #deep_traverse

Constructor Details

#initialize(fields: {}, universe: nil) ⇒ Base

Returns a new instance of Base.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/universe_compiler/entity.rb', line 25

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

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



21
22
23
# File 'lib/universe_compiler/entity.rb', line 21

def fields
  @fields
end

#universeObject

Returns the value of attribute universe.



21
22
23
# File 'lib/universe_compiler/entity.rb', line 21

def universe
  @universe
end

Instance Method Details

#[](key) ⇒ Object



49
50
51
# File 'lib/universe_compiler/entity.rb', line 49

def [](key)
  fields[key]
end

#[]=(key, value) ⇒ Object



53
54
55
# File 'lib/universe_compiler/entity.rb', line 53

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