Module: Chronicle::Schema::Validation::Generation

Defined in:
lib/chronicle/schema/validation/generation.rb

Class Method Summary collapse

Class Method Details

.generate_contracts(graph) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/chronicle/schema/validation/generation.rb', line 7

def self.generate_contracts(graph)
  return if @contracts_generated

  @graph = graph

  graph.types.each do |klass|
    type_id = klass.short_id.to_sym
    type_contract_class = Chronicle::Schema::Validation::ContractFactory.create(type_id:,
      properties: klass.all_properties)

    Chronicle::Schema::Validation.set_contract(type_id, type_contract_class)
  end

  @contracts_generated = true
end

.graphObject



23
24
25
# File 'lib/chronicle/schema/validation/generation.rb', line 23

def self.graph
  @graph
end