Skip Menu |

This queue is for tickets about the Net-AMQP CPAN distribution.

Report information
The Basics
Id: 104958
Status: new
Priority: 0/
Queue: Net-AMQP

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.06
Fixed in: (no value)



Subject: Add support for objects with stringification overloading
Currently it's not possible to supply a value for a header which is a blessed object with stringification overloading. For example #!perl use DateTime (); # sample class with stringify overloading use Net::AMQP::Common (); my $table = { now => DateTime->now }; Net::AMQP::Common::pack_field_table($table); __END__ would die with: No way to pack 2015-06-04T11:53:52 into AMQP array or table at /opt/perl-5.18.4/lib/site_perl/5.18.4/Net/AMQP/Common.pm line 232. This could be fixed by adding another conditional block into Net::AMQP::Common::_pack_field_value, which checks if stringification is possible (idea taken from http://stackoverflow.com/questions/2602321/how-can-i-determine-if-an-object-or-reference-has-a-valid-string-coercion ): elsif ("$value" ne overload::StrVal($value)) { 'S' . pack_long_string("$value"); } Or alternatively treat everything else as strings. Current workaround would be to force stringification earlier, or to pack the value into a Net::AMQP::Value::String object manually. Something like (untested): { now => "".DateTime->now } or { now => Net::AMQP::Value::String->new(DateTime->now) }