Module: UniverseCompiler::Entity::Inheritance
Instance Attribute Summary collapse
-
#compiled ⇒ Object
readonly
Returns the value of attribute compiled.
Instance Method Summary collapse
Methods included from FieldBinder
field_accessor, field_reader, field_writer
Instance Attribute Details
#compiled ⇒ Object (readonly)
Returns the value of attribute compiled.
9 10 11 |
# File 'lib/universe_compiler/entity/inheritance.rb', line 9 def compiled @compiled end |
Instance Method Details
#apply_inheritance ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/universe_compiler/entity/inheritance.rb', line 11 def apply_inheritance return unless compiled.nil? unless extends.nil? valid_for_inheritance? raise_error: true @fields = fields_inheritance_result end ensure @compiled = true end |
#valid_for_inheritance?(raise_error: false) ⇒ Boolean
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/universe_compiler/entity/inheritance.rb', line 21 def valid_for_inheritance?(raise_error: false) is_valid = true unless extends.nil? is_valid = false if extends.respond_to? :type and extends.respond_to? :name if extends.respond_to? :fields or extends.is_a? UniverseCompiler::Entity::Reference is_valid = self.type == extends.type end end end return true if is_valid false_or_raise "Invalid entity '#{to_composite_key}' ! Inheritance is invalid !", raise_error: raise_error end |