Sha256: f6c2ba98358dcbce4b335f5279188adaa3261eeaceacd9d8479b7b9ec6e0aa49

Contents?: true

Size: 1.01 KB

Versions: 29

Compression:

Stored size: 1.01 KB

Contents

module UniverseCompiler
  module Universe

    module Validation

      def valid?(raise_error: false)
        entities.each do |entity|
          UniverseCompiler.logger.debug "Checking '#{entity.to_composite_key}'"
          deep_map entity.fields do |leaf|
            case leaf
            when UniverseCompiler::Entity::Reference
              return false_or_raise "Entity '#{entity.to_composite_key}' contains an invalid reference to '#{leaf.to_composite_key}' !", raise_error: raise_error
            when UniverseCompiler::Entity::Base
              unless leaf.universe == self
                return false_or_raise "Entity '#{leaf.to_composite_key}' is not in the correct universe !", raise_error: raise_error
              end
              unless entities.include? leaf
                return false_or_raise "Entity '#{leaf.to_composite_key}' is not present in unniverse !", raise_error: raise_error
              end
            end
          end
          entity.valid?
        end
        true
      end

    end

  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
universe_compiler-0.5.6 lib/universe_compiler/universe/validation.rb
universe_compiler-0.5.5 lib/universe_compiler/universe/validation.rb
universe_compiler-0.5.4 lib/universe_compiler/universe/validation.rb
universe_compiler-0.5.3 lib/universe_compiler/universe/validation.rb
universe_compiler-0.5.2 lib/universe_compiler/universe/validation.rb
universe_compiler-0.5.1 lib/universe_compiler/universe/validation.rb
universe_compiler-0.4.3 lib/universe_compiler/universe/validation.rb
universe_compiler-0.4.2 lib/universe_compiler/universe/validation.rb
universe_compiler-0.4.1 lib/universe_compiler/universe/validation.rb
universe_compiler-0.4.0 lib/universe_compiler/universe/validation.rb
universe_compiler-0.3.12 lib/universe_compiler/universe/validation.rb
universe_compiler-0.3.11 lib/universe_compiler/universe/validation.rb
universe_compiler-0.3.10 lib/universe_compiler/universe/validation.rb
universe_compiler-0.3.9 lib/universe_compiler/universe/validation.rb
universe_compiler-0.3.8 lib/universe_compiler/universe/validation.rb
universe_compiler-0.3.7 lib/universe_compiler/universe/validation.rb
universe_compiler-0.3.6 lib/universe_compiler/universe/validation.rb
universe_compiler-0.3.5 lib/universe_compiler/universe/validation.rb
universe_compiler-0.3.4 lib/universe_compiler/universe/validation.rb
universe_compiler-0.3.3 lib/universe_compiler/universe/validation.rb