Class: CSV2Avro::DatumWriter
- Inherits:
-
Avro::IO::DatumWriter
- Object
- Avro::IO::DatumWriter
- CSV2Avro::DatumWriter
- Defined in:
- lib/csv2avro/datum_writer.rb
Instance Attribute Summary collapse
-
#schema_validator ⇒ Object
readonly
Returns the value of attribute schema_validator.
Instance Method Summary collapse
-
#initialize(*args) ⇒ DatumWriter
constructor
A new instance of DatumWriter.
- #write(datum, encoder) ⇒ Object
Constructor Details
#initialize(*args) ⇒ DatumWriter
Returns a new instance of DatumWriter.
9 10 11 12 |
# File 'lib/csv2avro/datum_writer.rb', line 9 def initialize(*args) super @schema_validator = CSV2Avro::SchemaValidator.new end |
Instance Attribute Details
#schema_validator ⇒ Object (readonly)
Returns the value of attribute schema_validator.
7 8 9 |
# File 'lib/csv2avro/datum_writer.rb', line 7 def schema_validator @schema_validator end |
Instance Method Details
#write(datum, encoder) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/csv2avro/datum_writer.rb', line 14 def write(datum, encoder) schema_validator.clear if !schema_validator.validate(writers_schema, datum) raise SchemaValidationError.new(schema_validator.errors) end super end |