lib/amqp/client/properties.rb in amqp-client-0.3.0 vs lib/amqp/client/properties.rb in amqp-client-1.0.0
- old
+ new
@@ -36,11 +36,12 @@
arr << tbl.bytesize << tbl
fmt << "L>a*"
end
if delivery_mode
- headers.is_a?(Integer) || raise(ArgumentError, "delivery_mode must be an int")
+ delivery_mode.is_a?(Integer) || raise(ArgumentError, "delivery_mode must be an int")
+ delivery_mode.between?(0, 2) || raise(ArgumentError, "delivery_mode must be be between 0 and 2")
flags |= (1 << 12)
arr << delivery_mode
fmt << "C"
end
@@ -67,11 +68,11 @@
arr << reply_to.bytesize << reply_to
fmt << "Ca*"
end
if expiration
- expiration = expiration.to_s if expiration.is_a?(Integer)
+ self.expiration = expiration.to_s if expiration.is_a?(Integer)
expiration.is_a?(String) || raise(ArgumentError, "expiration must be a string or integer")
flags |= (1 << 8)
arr << expiration.bytesize << expiration
fmt << "Ca*"
@@ -84,10 +85,10 @@
arr << message_id.bytesize << message_id
fmt << "Ca*"
end
if timestamp
- timestamp.is_a?(Time) || raise(ArgumentError, "timestamp must be a time")
+ timestamp.is_a?(Integer) || timestamp.is_a?(Time) || raise(ArgumentError, "timestamp must be an Integer or a Time")
flags |= (1 << 6)
arr << timestamp.to_i
fmt << "Q>"
end