With a Moose object I am passing the value of an object attribute to the execute method of a DBI statement handle, i.e. something like:
$sth = $dbh->prepare(...);
$sth->execute($obj->now);
where
$obj is a Moose object. I've been told by my DBAs that the bind parameter is being treated as a string instead of a number which is causing my query to run slowly. I could fix this by writing:
$sth->execute(0+$obj->now);
However, I'm using
$obj->now in many places.
Question: How can I declare the 'now' attribute of $obj so that on gets it will ensure that the value returned is a number (or undef). Currently, 'now' is simply defined as:
has now => ( is => 'rw' );