Class: Avro::Builder::SchemaStore
- Inherits:
-
Object
- Object
- Avro::Builder::SchemaStore
- Defined in:
- lib/avro/builder/schema_store.rb
Overview
This class implements a schema store that loads Avro::Builder DSL files and returns Avro::Schema objects. It implements the same API as AvroTurf::SchemaStore.
Instance Method Summary collapse
- #find(name, namespace = nil) ⇒ Object
-
#initialize(path: nil) ⇒ SchemaStore
constructor
A new instance of SchemaStore.
Constructor Details
#initialize(path: nil) ⇒ SchemaStore
Returns a new instance of SchemaStore.
7 8 9 10 |
# File 'lib/avro/builder/schema_store.rb', line 7 def initialize(path: nil) Avro::Builder.add_load_path(path) if path @schemas = {} end |
Instance Method Details
#find(name, namespace = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/avro/builder/schema_store.rb', line 12 def find(name, namespace = nil) fullname = Avro::Name.make_fullname(name, namespace) @schemas[fullname] ||= Avro::Builder::DSL.new { eval_file(fullname) } .as_schema.tap do |schema| if schema.respond_to?(:fullname) && schema.fullname != fullname raise SchemaError.new(schema.fullname, fullname) end end end |