Class: RabbitMQ::FFI::BasicProperties Private
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- RabbitMQ::FFI::BasicProperties
- Defined in:
- lib/rabbitmq/ffi.rb,
lib/rabbitmq/ffi/ext/basic_properties.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.
Constant Summary collapse
- FLAGS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ content_type: (1 << 15), content_encoding: (1 << 14), headers: (1 << 13), delivery_mode: (1 << 12), priority: (1 << 11), correlation_id: (1 << 10), reply_to: (1 << 9), expiration: (1 << 8), message_id: (1 << 7), timestamp: (1 << 6), type: (1 << 5), user_id: (1 << 4), app_id: (1 << 3), cluster_id: (1 << 2), }
Instance Method Summary collapse
- #apply(**params) ⇒ Object private
- #flag_for_key?(key) ⇒ Boolean private
- #free! ⇒ Object private
- #set_flag_for_key(key) ⇒ Object private
- #to_h(free = false) ⇒ Object private
Instance Method Details
#apply(**params) ⇒ 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.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rabbitmq/ffi/ext/basic_properties.rb', line 6 def apply(**params) params.each do |key, value| next if value.nil? case value when String; value = FFI::Bytes.from_s(value) when Hash; value = FFI::Table.from(value) end set_flag_for_key(key) self[key] = value end self end |
#flag_for_key?(key) ⇒ Boolean
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.
48 49 50 51 52 53 |
# File 'lib/rabbitmq/ffi/ext/basic_properties.rb', line 48 def flag_for_key?(key) return false if key == :_flags flag_bit = FLAGS[key] return true unless flag_bit return (flag_bit & self[:_flags]) != 0 end |
#free! ⇒ 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.
35 36 37 38 39 40 |
# File 'lib/rabbitmq/ffi/ext/basic_properties.rb', line 35 def free! self.values.each do |item| item.free! if item.respond_to? :free! end clear end |
#set_flag_for_key(key) ⇒ 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.
42 43 44 45 46 |
# File 'lib/rabbitmq/ffi/ext/basic_properties.rb', line 42 def set_flag_for_key(key) flag_bit = FLAGS[key] return unless flag_bit self[:_flags] = (self[:_flags] | flag_bit) end |
#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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rabbitmq/ffi/ext/basic_properties.rb', line 19 def to_h(free=false) result = {} self.members.each do |key| [key, self[key]] next unless flag_for_key?(key) value = self[key] case value when FFI::Bytes; value = value.to_s(free) when FFI::Table; value = value.to_h(free) end result[key] = value end clear if free result end |