https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29746
Tomás Cohen Arazi <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|release-notes-needed | Text to go in the| |This development introduces release notes| |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} ) ); | | | | } | |``` -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
