pbrumm/pg_data_encoder — pull request #4 by drumsrgr8forn8 (2013-10-09 20:49:00+00:00)
Title: Raises error on close if now rows have been added...

Before this if you instantiated an encoder and accidently tried to copy
to a table without adding anything to the encoder it would just throw
the error:

```
NoMethodError: undefined method `write` for nil:NilClass from ...../encoder_for_copy.rb:22:in `close`
```

Now if something happened like:

```ruby
encoder = PgDataEncoder::EncodeForCopy.new(use_tempfile: true)

collection.each do |thing|
if impossible_thing # this is never true
encoder.add(thing.id, thing.name, thing.other_thing)
end
Thing.pg_copy_from(encoder.get_io, format: :binary, columns: [:id, :name, :other_thing])
```

Instead of throwing a NoMethodError you'll get a more helpful error to
put you on the right track.