Class: EventEngine::EventSchemaJsonLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/event_engine/event_schema_json_loader.rb

Class Method Summary collapse

Class Method Details

.load(path) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/event_engine/event_schema_json_loader.rb', line 5

def self.load(path)
  registry = SchemaRegistry.new
  return registry unless File.exist?(path)

  contents = File.read(path.to_s)
  return registry if contents.strip.empty?

  JSON.parse(contents).each do |attributes|
    registry.register(CatalogEntry.from_h(attributes))
  end

  registry
end