class Projector::Envelope

Wraps all requests to the Projector API in an envelope specifying data as an explicit parameter. @api private

Attributes

data[RW]

@return [Hash] data to be delivered to the Projector API

Public Class Methods

new(data) click to toggle source

@param [Object] data the data hash or array containing parameters for the API call

# File lib/projector/envelope.rb, line 9
def initialize(data)
  @data = data
end

Public Instance Methods

payload() click to toggle source

Returns the payload of the envelope @return [Object]

# File lib/projector/envelope.rb, line 15
def payload
  data.respond_to?(:to_hash) ? data.to_hash : data
end
to_hash(params = {}) click to toggle source

Serializes the envelope to the correct Projector-defined envelope hash format @return [Hash]

# File lib/projector/envelope.rb, line 21
def to_hash(params = {})
  raise Projector::Error::InvalidEnvelope unless @data
  {
    data: payload
  }
end