Class: RabbitMQ::FFI::Frame Private

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/rabbitmq/ffi.rb,
lib/rabbitmq/ffi/ext/frame.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#as_body_to_s(free = false) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (FFI::Error::BadAmqpData)


33
34
35
36
37
38
39
# File 'lib/rabbitmq/ffi/ext/frame.rb', line 33

def as_body_to_s(free=false)
  raise FFI::Error::BadAmqpData,
    "Wrong frame type for body frame of multiframe event: #{self[:frame_type]}" \
      unless self[:frame_type] == :body
  
  self[:payload][:body_fragment].to_s(free)
end

#as_header_to_h(free = false) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (FFI::Error::BadAmqpData)


24
25
26
27
28
29
30
31
# File 'lib/rabbitmq/ffi/ext/frame.rb', line 24

def as_header_to_h(free=false)
  raise FFI::Error::BadAmqpData,
    "Wrong frame type for header frame of multiframe event: #{self[:frame_type]}" \
      unless self[:frame_type] == :header
  
  properties = self[:payload][:properties]
  { header: properties.decoded.to_h(free), body_size: properties[:body_size] }
end

#as_method_to_h(free = false) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (FFI::Error::BadAmqpData)


16
17
18
19
20
21
22
# File 'lib/rabbitmq/ffi/ext/frame.rb', line 16

def as_method_to_h(free=false)
  raise FFI::Error::BadAmqpData,
    "Wrong frame type for method frame of event: #{self[:frame_type]}" \
      unless self[:frame_type] == :method
  
  payload.to_h(free).merge(channel: self[:channel])
end

#payloadObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
9
10
11
12
13
14
# File 'lib/rabbitmq/ffi/ext/frame.rb', line 6

def payload
  member = case self[:frame_type]
  when :method; :method
  when :header; :properties
  when :body;   :body_fragment
  else; raise NotImplementedError, "frame type: #{self[:frame_type]}"
  end
  self[:payload][member]
end