Module: Carrot::AMQP::Protocol

Defined in:
lib/carrot/amqp/spec.rb,
lib/carrot/amqp/spec.rb,
lib/carrot/amqp/protocol.rb

Defined Under Namespace

Classes: Access, Basic, Channel, Class, Connection, Dtx, Exchange, File, Header, Queue, Stream, Test, Tunnel, Tx

Class Method Summary collapse

Class Method Details

.Class(id, name) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/carrot/amqp/spec.rb', line 118

def self.Class(id, name)
  @_base_classes ||= {}
  @_base_classes[id] ||= ::Class.new(Class) do
    class_eval %[
      def self.inherited klass
        klass.const_set(:ID, #{id})
        klass.const_set(:NAME, :#{name.to_s})
        Protocol.classes[#{id}] = klass
        Protocol.classes[klass::NAME] = klass
      end
    ]
  end
end

.classesObject



116
# File 'lib/carrot/amqp/spec.rb', line 116

def self.classes() @classes ||= {} end

.parse(buf) ⇒ Object



151
152
153
154
155
# File 'lib/carrot/amqp/protocol.rb', line 151

def self.parse buf
  buf = Buffer.new(buf) unless buf.is_a? Buffer
  class_id, method_id = buf.read(:short, :short)
  classes[class_id].methods[method_id].new(buf)
end