View | Details | Raw Unified | Return to bug 19966
Collapse All | Expand All

(-)a/Koha/Object.pm (-1 / +19 lines)
Lines 222-227 sub unblessed { Link Here
222
    return { $self->_result->get_columns };
222
    return { $self->_result->get_columns };
223
}
223
}
224
224
225
=head3 $object->read_only();
226
227
Set the object as read_only, only getter methods will be allowed
228
229
=cut
230
231
sub read_only {
232
    my ($self) = @_;
233
234
    $self->{_read_only} = 1;
235
236
    return $self;
237
}
238
225
=head3 $object->TO_JSON
239
=head3 $object->TO_JSON
226
240
227
Returns an unblessed representation of the object, suitable for JSON output.
241
Returns an unblessed representation of the object, suitable for JSON output.
Lines 344-349 sub AUTOLOAD { Link Here
344
    # Using direct setter/getter like $item->barcode() or $item->barcode($barcode);
358
    # Using direct setter/getter like $item->barcode() or $item->barcode($barcode);
345
    if ( grep {/^$method$/} @columns ) {
359
    if ( grep {/^$method$/} @columns ) {
346
        if ( @_ ) {
360
        if ( @_ ) {
361
            die "Setter method $method called on read-only object"
362
                if $self->{_read_only};
347
            $self->_result()->set_column( $method, @_ );
363
            $self->_result()->set_column( $method, @_ );
348
            return $self;
364
            return $self;
349
        } else {
365
        } else {
Lines 352-357 sub AUTOLOAD { Link Here
352
        }
368
        }
353
    }
369
    }
354
370
371
    die "Cannot call method $method on a read-only object"
372
        if $self->{_read_only};
373
355
    my @known_methods = qw( is_changed id in_storage get_column discard_changes update );
374
    my @known_methods = qw( is_changed id in_storage get_column discard_changes update );
356
    Koha::Exceptions::Object::MethodNotCoveredByTests->throw( "The method $method is not covered by tests!" ) unless grep {/^$method$/} @known_methods;
375
    Koha::Exceptions::Object::MethodNotCoveredByTests->throw( "The method $method is not covered by tests!" ) unless grep {/^$method$/} @known_methods;
357
376
358
- 

Return to bug 19966