Module: Jackal::Utils::Payload
- Included in:
- Carnivore::Http::PointBuilder::Endpoint, Callback, Jackal::Utils
- Defined in:
- lib/jackal/utils/payload.rb
Overview
Payload helper utilities
Instance Method Summary collapse
-
#new_payload(name, payload, *args) ⇒ Smash
Generate a new payload.
-
#unpack(message) ⇒ Smash
Extract payload from message.
Instance Method Details
#new_payload(name, payload, *args) ⇒ Smash
Generate a new payload
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 => Carnivore.uuid, :data => payload ) end |
#unpack(message) ⇒ Smash
Extract payload from message
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jackal/utils/payload.rb', line 27 def unpack() if([:content]) result = [:content].to_smash else msg = [:message].to_smash result = msg.fetch(:payload, msg) end if(respond_to?(:pre_formatters) && (pre_formatters && !pre_formatters.empty?)) pre_formatters.each do |formatter| begin formatter.format(result) rescue => e error "Formatter error encountered (<#{formatter}>): #{e.class} - #{e}" end end end result end |