Venus::Kind::Value

Value Base Class

Value Base Class for Perl 5

method: cast method: defined method: explain method: mutate

package Example;

use Venus::Class;

base 'Venus::Kind::Value';

sub test {
  $_[0]->get + 1
}

package main;

my $example = Example->new(1);

# $example->defined;

This package provides identity and methods common across all Venus value classes.

Venus::Kind

Venus::Role::Accessible Venus::Role::Buildable Venus::Role::Explainable Venus::Role::Pluggable Venus::Role::Proxyable Venus::Role::Valuable

The cast method converts "value" objects between different "value" object types, based on the name of the type provided. This method will return undef if the invocant is not a Venus::Kind::Value.

cast(string $kind) (object | undef)

{ since => '0.08', }

=example-1 cast

package main;

my $example = Example->new;

my $cast = $example->cast;

# bless({value => undef}, "Venus::Undef")

The defined method returns truthy or falsy if the underlying value is "defined".

defined() (number)

{ since => '0.01', }

=example-1 defined

package main;

my $example = Example->new;

my $defined = $example->defined;

# 0

The explain method returns the value set and is used in stringification operations.

explain() (any)

{ since => '0.01', }

=example-1 explain

package main;

my $example = Example->new('hello, there');

my $explain = $example->explain;

# "hello, there"

The mutate method dispatches the method call or executes the callback and returns the result, which if is of the same type as the invocant's underlying data type will update the object's internal state or will throw an exception.

mutate(string | coderef $code, any @args) (object)

{ since => '1.23', }

=example-1 mutate

# given: synopsis

package main;

$example->mutate('test');

$example;

# bless({value => 2}, "Example")

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

24 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 50:

Unknown directive: =synopsis

Around line 78:

Unknown directive: =description

Around line 87:

Unknown directive: =inherits

Around line 95:

Unknown directive: =integrates

Around line 108:

Unknown directive: =method

Around line 114:

Unknown directive: =signature

Around line 118:

Unknown directive: =metadata

Around line 157:

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

Around line 180:

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

Around line 191:

Unknown directive: =method

Around line 196:

Unknown directive: =signature

Around line 200:

Unknown directive: =metadata

Around line 235:

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

Around line 245:

Unknown directive: =method

Around line 250:

Unknown directive: =signature

Around line 254:

Unknown directive: =metadata

Around line 280:

Unknown directive: =method

Around line 286:

Unknown directive: =signature

Around line 290:

Unknown directive: =metadata

Around line 325:

Unknown directive: =partials