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 16:

Unknown directive: =name

Around line 24:

Unknown directive: =tagline

Around line 32:

Unknown directive: =abstract

Around line 40:

Unknown directive: =includes

Around line 48:

Unknown directive: =synopsis

Around line 94:

Unknown directive: =description

Around line 103:

Unknown directive: =method

Around line 108:

Unknown directive: =signature

Around line 112:

Unknown directive: =metadata

Around line 162:

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

Around line 190:

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

Around line 202:

Unknown directive: =partials