Module: Sequel::Plugins::Protobuf::DatasetMethods

Defined in:
lib/sequel/plugins/protobuf.rb

Overview

When mixed in, this module provides the ability for Sequel datasets to call to_protobuf, which will return an array of serialized protobuf strings.

Instance Method Summary collapse

Instance Method Details

#to_protobuf(options = {}) ⇒ Array

Renders the current dataset of the model into a collection of protocol buffer messages as they are defined in the configured protocol buffer model definition.

Parameters:

  • options (Hash) (defaults to: {})

    . An options hash that is used to configure how the rendering is preformed.

Returns:

  • (Array)

    . An array of protocol buffer messages. Each element In the array is a serialized version of the corresponding object in the original dataset.



182
183
184
185
186
187
188
189
190
191
# File 'lib/sequel/plugins/protobuf.rb', line 182

def to_protobuf(options = {})

  res = self.all.inject([]) do |acc, obj|
    acc << obj.to_protobuf(options)
    acc
  end
  
  return res
  
end