1 package Koha::Result::Boolean;
3 # Copyright ByWater Solutions 2021
4 # Copyright Theke Solutions 2021
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use overload bool => \&as_bool;
25 use Koha::Object::Message;
29 Koha::Result::Boolean - Booleans, with extra Koha
37 my $bool = Koha::Result::Boolean->new( $value );
39 Constructor method to generate a Koha::Result::Boolean object. I<value> is
45 my ( $class, $value ) = @_;
47 $value //= 1; # default to true
48 $value = ($value) ? 1 : 0;
55 return bless ( $self, $class );
63 Set the boolean value for the object.
68 my ( $self, $value ) = @_;
70 $self->{value} = ($value) ? 1 : 0;
77 my @messages = @{ $bool->messages };
79 Returns the I<Koha::Object::Message> objects that were recorded.
86 $self->{_messages} = []
87 unless defined $self->{_messages};
89 return $self->{_messages};
107 my ( $self, $params ) = @_;
109 push @{ $self->{_messages} }, Koha::Object::Message->new($params);
114 =head2 Internal methods
118 Internal method that exposes the boolean value of the object
125 return $self->{value};
130 Tomas Cohen Arazi, E<lt>tomascohen@theke.ioE<gt>