Venus::Role::Deferrable

Deferrable Role

Deferrable Role for Perl 5

method: defer

package Example;

use Venus::Class;

with 'Venus::Role::Deferrable';

sub test {
  my ($self, @args) = @_;

  return $self->okay(@args);
}

sub okay {
  my ($self, @args) = @_;

  return [@args];
}

package main;

my $example = Example->new;

# my $code = $example->defer('test');

# sub {...}

# $code->();

# [...]

This package provides a mechanism for returning callbacks (i.e. closures) that dispatches method calls.

The defer method returns the named method as a callback (i.e. closure) which dispatches to the method call specified.

defer(string $method, any @args) (coderef)

{ since => '1.80', }

=example-1 defer

# given: synopsis

package main;

$example = Example->new;

# bless({}, 'Example')

# my $result = $example->defer('test', 1..4);

# $result->();

# [1..4]

t/Venus.t: present: authors t/Venus.t: present: license

12 POD Errors

The following errors were encountered while parsing the POD:

Around line 15:

Unknown directive: =name

Around line 23:

Unknown directive: =tagline

Around line 31:

Unknown directive: =abstract

Around line 39:

Unknown directive: =includes

Around line 47:

Unknown directive: =synopsis

Around line 93:

Unknown directive: =description

Around line 102:

Unknown directive: =method

Around line 107:

Unknown directive: =signature

Around line 111:

Unknown directive: =metadata

Around line 161:

=cut found outside a pod block. Skipping to next block.

Around line 189:

=cut found outside a pod block. Skipping to next block.

Around line 201:

Unknown directive: =partials