Sha256: 845da346e1c1aef968e28fcb59cfae8e4a2d6c3e7450c9f841f1440c9e0bb7fc

Contents?: true

Size: 755 Bytes

Versions: 12

Compression:

Stored size: 755 Bytes

Contents

module Avro
  module Builder
    # 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.
    class SchemaStore
      def initialize(path: nil)
        Avro::Builder.add_load_path(path) if path
        @schemas = {}
      end

      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
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
avro-builder-0.16.1 lib/avro/builder/schema_store.rb
avro-builder-0.16.0 lib/avro/builder/schema_store.rb
avro-builder-0.15.0 lib/avro/builder/schema_store.rb
avro-builder-0.15.0.rc0 lib/avro/builder/schema_store.rb
avro-builder-0.14.1 lib/avro/builder/schema_store.rb
avro-builder-0.14.0 lib/avro/builder/schema_store.rb
avro-builder-0.13.0 lib/avro/builder/schema_store.rb
avro-builder-0.12.0 lib/avro/builder/schema_store.rb
avro-builder-0.11.0 lib/avro/builder/schema_store.rb
avro-builder-0.10.0 lib/avro/builder/schema_store.rb
avro-builder-0.9.0 lib/avro/builder/schema_store.rb
avro-builder-0.8.0 lib/avro/builder/schema_store.rb