Class: Kril::SchemaHandler
- Inherits:
-
Object
- Object
- Kril::SchemaHandler
- Defined in:
- lib/kril/schema_handler.rb
Overview
Saves schemas to repository.
Instance Method Summary collapse
-
#initialize(schemas_path:, schema_store: nil) ⇒ SchemaHandler
constructor
schemas_path - directory of schema repository [String] schema_store - schema store [AvroTurf::SchemaStore].
-
#process(input_string) ⇒ Object
Handles input to reference or create schema.
Constructor Details
#initialize(schemas_path:, schema_store: nil) ⇒ SchemaHandler
schemas_path - directory of schema repository [String] schema_store - schema store [AvroTurf::SchemaStore]
8 9 10 11 12 13 |
# File 'lib/kril/schema_handler.rb', line 8 def initialize(schemas_path:, schema_store: nil) schema_store ||= AvroTurf::SchemaStore.new(path: schemas_path) @schema_store = schema_store @schemas_path = schemas_path end |
Instance Method Details
#process(input_string) ⇒ Object
Handles input to reference or create schema.
input_string - schema name, schema file, or schema contents [String] returns - stored schema [Avro::Schema]
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kril/schema_handler.rb', line 19 def process(input_string) return nil unless input_string name, namespace = if File.exist?(input_string) copy_schema_to_store(input_string) elsif schema?(input_string) save_schema(input_string) else separate_fullname(input_string) end @schema_store.find(name, namespace) end |