Text to go in the release notes:
|
This development introduces a new library, Koha::Result::Boolean, that will be used in method that need to return a boolean, but could also want to carry some more information such as the reason for a 'false' return value.
A Koha::Result::Boolean object will be evaluated as a boolean in bool context, while retaining its object nature and methods.
For example, suppose a $patron object should not be deleted because the patron it represents has a guarantee:
```
if ( $patron->safe_to_delete ) { ... }
```
will eval to false, and the code will do what we expect.
If our code really wanted to know *why* it cannot be deleted, we can do:
```
my $result = $patron->safe_to_delete;
unless ( $result ) {
Koha::Exceptions->throw( "Cannot delete, errors: " . join( ', ', map {$_->message} @{$result->messages} ) );
}
```
|