Sha256: 53dafe1035e92b1f561478ceda29dc34109d70ab95498124125680b84d9fd33f

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

require 'synapses'
require 'json'

module Synapses
  # @author Alexander Semyonov <al@semyonov.us>
  module Messages
    extend ActiveSupport::Concern

    def self.registry
      @registry ||= {}
    end

    # @param [AMQP::Header] metadata
    # @param [String] payload
    def self.parse(metadata, payload)
      if (message_type = registry[metadata.type])
        message_type.parse(metadata, payload)
      else
        Message.new
      end
    end

    included do
      const_set(:Message, Synapses::Messages::Message)
    end
  end
end

require 'synapses/messages/message'
require 'synapses/messages/coders'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
synapses-0.0.1 lib/synapses/messages.rb