Venus::Kind - Kind Base Class
Kind Base Class for Perl 5
package Example; use Venus::Class; base 'Venus::Kind'; package main; my $example = Example->new;
This package provides identity and methods common across all Venus classes.
This package integrates behaviors from:
Venus::Role::Boxable
Venus::Role::Catchable
Venus::Role::Comparable
Venus::Role::Digestable
Venus::Role::Doable
Venus::Role::Dumpable
Venus::Role::Matchable
Venus::Role::Printable
Venus::Role::Testable
Venus::Role::Throwable
This package provides the following methods:
checksum() (Str)
The checksum method returns an md5 hash string representing the stringified object value (or the object itself).
Since 0.08
0.08
# given: synopsis; my $checksum = $example->checksum; # "859a86eed4b2d97eb7b830b02f06de32"
package Checksum::Example; use Venus::Class; base 'Venus::Kind'; attr 'value'; package main; my $example = Checksum::Example->new(value => 'example'); my $checksum = $example->checksum; # "1a79a4d60de6718e8e5b326e338ae533"
class() (Str)
The class method returns the class name for the given class or object.
Since 0.01
0.01
# given: synopsis; my $class = $example->class; # "Example"
numified() (Int)
The numified method returns the numerical representation of the object which is typically the length (or character count) of the stringified object.
# given: synopsis; my $numified = $example->numified; # 22
package Numified::Example; use Venus::Class; base 'Venus::Kind'; attr 'value'; package main; my $example = Numified::Example->new(value => 'example'); my $numified = $example->numified; # 7
safe(Str | CodeRef $code, Any @args) (Any)
The safe method dispatches the method call or executes the callback and returns the result, supressing warnings and exceptions. If an exception is thrown this method will return undef. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.
undef
# given: synopsis; my $safe = $example->safe('class'); # "Example"
# given: synopsis; my $safe = $example->safe(sub { ${_}->class / 2 }); # '0'
# given: synopsis; my $safe = $example->safe(sub { die; }); # undef
space() (Space)
The space method returns a Venus::Space object for the given object.
# given: synopsis; my $space = $example->space; # bless({ value => "Example" }, "Venus::Space")
stringified() (Str)
The stringified method returns the object, stringified (i.e. a dump of the object's value).
# given: synopsis; my $stringified = $example->stringified; # bless({}, 'Example')
package Stringified::Example; use Venus::Class; base 'Venus::Kind'; attr 'value'; package main; my $example = Stringified::Example->new(value => 'example'); my $stringified = $example->stringified; # "example"
trap(Str | CodeRef $code, Any @args) (Tuple[ArrayRef, ArrayRef, ArrayRef])
The trap method dispatches the method call or executes the callback and returns a tuple (i.e. a 3-element arrayref) with the results, warnings, and exceptions from the code execution. If an exception is thrown, the results (i.e. the 1st-element) will be an empty arrayref. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.
# given: synopsis; my $result = $example->trap('class'); # ["Example"]
# given: synopsis; my ($results, $warnings, $errors) = $example->trap('class'); # (["Example"], [], [])
# given: synopsis; my $trap = $example->trap(sub { ${_}->class / 2 }); # ["0"]
# given: synopsis; my ($results, $warnings, $errors) = $example->trap(sub { ${_}->class / 2 }); # (["0"], ["Argument ... isn't numeric in division ..."], [])
# given: synopsis; my $trap = $example->trap(sub { die; }); # []
# given: synopsis; my ($results, $warnings, $errors) = $example->trap(sub { die; }); # ([], [], ["Died..."])
type() (Type)
The type method returns a Venus::Type object for the given object.
# given: synopsis; my $type = $example->type; # bless({ value => bless({}, "Example") }, "Venus::Type")
To install Venus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Venus
CPAN shell
perl -MCPAN -e shell install Venus
For more information on module installation, please visit the detailed CPAN module installation guide.