Module: BSON::LogStashEvent::ClassMethods

Defined in:
lib/logstash/outputs/bson/logstash_event.rb

Instance Method Summary collapse

Instance Method Details

#from_bson(buffer) ⇒ Event

Deserialize the Event from BSON.

Parameters:

  • buffer (ByteBuffer)

    The byte buffer.

Returns:

  • (Event)

    The decoded bson document.

See Also:



58
59
60
61
62
63
64
65
66
# File 'lib/logstash/outputs/bson/logstash_event.rb', line 58

def from_bson(buffer)
  hash = Hash.new
  buffer.get_int32 # Throw away the size.
  while (type = buffer.get_byte) != NULL_BYTE
    field = buffer.get_cstring
    hash.store(field, BSON::Registry.get(type).from_bson(buffer))
  end
  new(hash)
end