NAME
Venus::Role::Resultable - Resultable Role
ABSTRACT
Resultable Role for Perl 5
SYNOPSIS
package Example;
use Venus::Class;
with 'Venus::Role::Resultable';
sub fail {
die 'failed';
}
sub pass {
return 'passed';
}
package main;
my $example = Example->new;
# $example->result('fail');
# bless(..., "Venus::Result")
DESCRIPTION
This package modifies the consuming package and provides a mechanism for returning dynamically dispatched subroutine calls as Venus::Result objects.
METHODS
This package provides the following methods:
result
result(string | coderef $callback, any @args) (Venus::Result)
The result method dispatches to the named method or coderef provided and returns a Venus::Result object containing the error or return value encountered.
Since 4.15
- result example 2
-
# given: synopsis; my $result = $example->result('pass'); # bless(..., "Venus::Result")
- result example 3
-
# given: synopsis; my $result = $example->result('fail'); # bless(..., "Venus::Result")
AUTHORS
Awncorp, awncorp@cpan.org
LICENSE
Copyright (C) 2022, Awncorp, awncorp@cpan.org.
This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.