|
Lines 378-383
sub add_message {
Link Here
|
| 378 |
my ( $self, $params ) = @_; |
378 |
my ( $self, $params ) = @_; |
| 379 |
|
379 |
|
| 380 |
push @{ $self->{_messages} }, Koha::Object::Message->new($params); |
380 |
push @{ $self->{_messages} }, Koha::Object::Message->new($params); |
|
|
381 |
} |
| 382 |
|
| 383 |
=head3 $object->read_only(); |
| 384 |
|
| 385 |
Set the object as read_only, only getter methods will be allowed |
| 386 |
|
| 387 |
=cut |
| 388 |
|
| 389 |
sub read_only { |
| 390 |
my ($self) = @_; |
| 391 |
|
| 392 |
$self->{_read_only} = 1; |
| 381 |
|
393 |
|
| 382 |
return $self; |
394 |
return $self; |
| 383 |
} |
395 |
} |
|
Lines 814-819
sub AUTOLOAD {
Link Here
|
| 814 |
# Using direct setter/getter like $item->barcode() or $item->barcode($barcode); |
826 |
# Using direct setter/getter like $item->barcode() or $item->barcode($barcode); |
| 815 |
if ( grep { $_ eq $method } @columns ) { |
827 |
if ( grep { $_ eq $method } @columns ) { |
| 816 |
if ( @_ ) { |
828 |
if ( @_ ) { |
|
|
829 |
die "Setter method $method called on read-only object" |
| 830 |
if $self->{_read_only}; |
| 817 |
$self->_result()->set_column( $method, @_ ); |
831 |
$self->_result()->set_column( $method, @_ ); |
| 818 |
return $self; |
832 |
return $self; |
| 819 |
} else { |
833 |
} else { |
|
Lines 822-827
sub AUTOLOAD {
Link Here
|
| 822 |
} |
836 |
} |
| 823 |
} |
837 |
} |
| 824 |
|
838 |
|
|
|
839 |
die "Cannot call method $method on a read-only object" |
| 840 |
if $self->{_read_only}; |
| 841 |
|
| 825 |
my @known_methods = qw( is_changed id in_storage get_column discard_changes make_column_dirty ); |
842 |
my @known_methods = qw( is_changed id in_storage get_column discard_changes make_column_dirty ); |
| 826 |
|
843 |
|
| 827 |
Koha::Exceptions::Object::MethodNotCoveredByTests->throw( |
844 |
Koha::Exceptions::Object::MethodNotCoveredByTests->throw( |
|
Lines 829-835
sub AUTOLOAD {
Link Here
|
| 829 |
show_trace => 1 |
846 |
show_trace => 1 |
| 830 |
) unless grep { $_ eq $method } @known_methods; |
847 |
) unless grep { $_ eq $method } @known_methods; |
| 831 |
|
848 |
|
| 832 |
|
|
|
| 833 |
if ( $method eq 'update' ) { |
849 |
if ( $method eq 'update' ) { |
| 834 |
return $self if ( ( caller() )[0] eq 'Template::Document' ); |
850 |
return $self if ( ( caller() )[0] eq 'Template::Document' ); |
| 835 |
} |
851 |
} |
| 836 |
- |
|
|