Module: Jackal::Utils::Payload

Included in:
Carnivore::Http::PointBuilder::Endpoint, Callback, Callback, Jackal::Utils
Defined in:
lib/jackal/utils/payload.rb

Overview

Payload helper utilities

Instance Method Summary collapse

Instance Method Details

#new_payload(name, payload, *args) ⇒ Smash

Generate a new payload

Parameters:

  • name (String)
  • payload (Hash)
  • args (Object)

    extra arguments

Returns:

  • (Smash)


15
16
17
18
19
20
21
# File 'lib/jackal/utils/payload.rb', line 15

def new_payload(name, payload, *args)
  Smash.new(
    :name => name,
    :id => Celluloid.uuid,
    :data => payload
  )
end

#unpack(message) ⇒ Smash

Extract payload from message

Parameters:

  • message (Carnivore::Message)

Returns:

  • (Smash)


27
28
29
30
# File 'lib/jackal/utils/payload.rb', line 27

def unpack(message)
  msg = message[:message].to_smash
  msg.fetch(:payload, msg)
end