lib/avro/builder/dsl.rb in avro-builder-0.2.0 vs lib/avro/builder/dsl.rb in avro-builder-0.3.0

- old
+ new

@@ -2,11 +2,10 @@ require 'avro/builder/dsl_attributes' require 'avro/builder/namespaceable' require 'avro/builder/type_factory' require 'avro/builder/types' require 'avro/builder/field' -require 'avro/builder/record' require 'avro/builder/file_handler' require 'avro/builder/schema_serializer_reference_state' module Avro module Builder @@ -83,10 +82,12 @@ # Return the last schema object processed as an Avro JSON schema def to_json(validate: true, pretty: true) hash = to_h (pretty ? JSON.pretty_generate(hash) : hash.to_json).tap do |json| + # Uncomment the next line to debug: + # puts json # Parse the schema to validate before returning ::Avro::Schema.parse(json) if validate end end @@ -109,13 +110,14 @@ schema_objects[object.name.to_s] = object schema_objects[object.fullname] = object if object.namespace end def build_record(name, options, &block) - Record.new(name, options.merge(namespace: namespace)).tap do |record| - record.builder = builder - record.instance_eval(&block) - end + Avro::Builder::Types::RecordType + .new(name, options.merge(namespace: namespace)).tap do |record| + record.builder = builder + record.instance_eval(&block) + end end def eval_file(name) instance_eval(read_file(name)) end