if ($attributes) {
$self->{_result} =
- Koha::Database->new()->schema()->resultset( $class->type() )
+ Koha::Database->new()->schema()->resultset( $class->_type() )
->new($attributes);
}
- croak("No type found! Koha::Object must be subclassed!")
- unless $class->type();
+ croak("No _type found! Koha::Object must be subclassed!")
+ unless $class->_type();
bless( $self, $class );
# DBIC result row
$self->{_result} = $dbic_row;
- croak("No type found! Koha::Object must be subclassed!")
- unless $class->type();
+ croak("No _type found! Koha::Object must be subclassed!")
+ unless $class->_type();
- croak( "DBIC result type " . ref( $self->{_result} ) . " isn't of the type " . $class->type() )
- unless ref( $self->{_result} ) eq "Koha::Schema::Result::" . $class->type();
+ croak( "DBIC result _type " . ref( $self->{_result} ) . " isn't of the _type " . $class->_type() )
+ unless ref( $self->{_result} ) eq "Koha::Schema::Result::" . $class->_type();
bless( $self, $class );
# If we don't have a dbic row at this point, we need to create an empty one
$self->{_result} ||=
- Koha::Database->new()->schema()->resultset( $self->type() )->new({});
+ Koha::Database->new()->schema()->resultset( $self->_type() )->new({});
return $self->{_result};
}
return;
}
-=head3 type
+=head3 _type
This method must be defined in the child class. The value is the name of the DBIC resultset.
-For example, for borrowers, the type method will return "Borrower".
+For example, for borrowers, the _type method will return "Borrower".
=cut
-sub type { }
+sub _type { }
sub DESTROY { }
use Koha::Database;
-our $type;
-
=head1 NAME
Koha::Objects - Koha Object set base class
if ( ref($self) ) {
$self->{_resultset} ||=
- Koha::Database->new()->schema()->resultset( $self->type() );
+ Koha::Database->new()->schema()->resultset( $self->_type() );
return $self->{_resultset};
}
else {
- return Koha::Database->new()->schema()->resultset( $self->type() );
+ return Koha::Database->new()->schema()->resultset( $self->_type() );
}
}
-=head3 type
+=head3 _type
-The type method must be set for all child classes.
+The _type method must be set for all child classes.
The value returned by it should be the DBIC resultset name.
-For example, for holds, type should return 'Reserve'.
+For example, for holds, _type should return 'Reserve'.
=cut
-sub type { }
+sub _type { }
=head3 object_class