class AMQ::Protocol::Method
def self.encode_body(body, channel, frame_size)
def self.encode_body(body, channel, frame_size) return [] if body.empty? # 8 = 1 + 2 + 4 + 1 # 1 byte of frame type # 2 bytes of channel number # 4 bytes of frame payload length # 1 byte of payload trailer FRAME_END byte limit = frame_size - 8 return [BodyFrame.new(body, channel)] if body.bytesize < limit # Otherwise String#slice on 1.9 will operate with code points, # and we need bytes. MK. body.force_encoding("ASCII-8BIT") if RUBY_VERSION.to_f >= 1.9 && body.encoding != Encoding::BINARY array = Array.new while body && !body.empty? payload, body = body[0, limit], body[limit, body.length - limit] array << BodyFrame.new(payload, channel) end array end
def self.index
def self.index @index end
def self.inherited(base)
def self.inherited(base) if self == Protocol::Method @methods << base end end
def self.instantiate(*args, &block)
def self.instantiate(*args, &block) self.new(*args, &block) end
def self.method_id
def self.method_id @method_id end
def self.methods
def self.methods @methods end
def self.name
def self.name @name end
def self.split_headers(user_headers)
def self.split_headers(user_headers) properties, headers = {}, {} user_headers.each do |key, value| # key MUST be a symbol since symbols are not garbage-collected if Basic::PROPERTIES.include?(key) properties[key] = value else headers[key] = value end end return [properties, headers] end