The Perl Advent Calendar needs more articles for 2022. Submit your idea today!

NAME

Venus::Role::Doable - Doable Role

ABSTRACT

Doable Role for Perl 5

SYNOPSIS

  package Example;

  use Venus::Class;

  with 'Venus::Role::Doable';

  attr 'time';

  sub execute {
    return;
  }

  package main;

  my $example = Example->new;

  # $example->do(time => time)->execute;

DESCRIPTION

This package modifies the consuming package and provides methods for chaining any chainable and non-chainable methods (by ignoring their return values).

METHODS

This package provides the following methods:

do

  do(Str | CodeRef $method, Any @args) (Self)

The do method dispatches the method call or executes the callback and returns the invocant. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.

Since 0.01

do example 1
  package main;

  my $example = Example->new;

  $example = $example->do(time => time);

  # bless({ time => 0000000000 }, "Example")

  # $example->execute;