By returning the object itself instead of a boolean, we can chain
methods together while retaining the exact same functionality.
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
sub store {
my ($self) = @_;
- return $self->_result()->update_or_insert() ? 1 : 0;
+ return $self->_result()->update_or_insert() ? $self : undef;
}
=head3 $object->in_storage();
}
}
- return $self->_result()->set_columns($properties) ? 1 : undef;
+ return $self->_result()->set_columns($properties) ? $self : undef;
}
=head3 $object->id();
sub find {
my ( $self, $id ) = @_;
+ return unless $id;
+
my $result = $self->_resultset()->find($id);
my $object = $self->object_class()->_new_from_dbic( $result );