GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Venus::Kind(3) User Contributed Perl Documentation Venus::Kind(3)

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;
  # bless({}, "Example")

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

This package integrates behaviors from:

Venus::Role::Assertable

Venus::Role::Boxable

Venus::Role::Catchable

Venus::Role::Comparable

Venus::Role::Deferrable

Venus::Role::Digestable

Venus::Role::Doable

Venus::Role::Dumpable

Venus::Role::Matchable

Venus::Role::Mockable

Venus::Role::Patchable

Venus::Role::Printable

Venus::Role::Reflectable

Venus::Role::Serializable

Venus::Role::Testable

Venus::Role::Throwable

Venus::Role::Tryable

This package provides the following methods:

  assertion() (Venus::Assert)

The assertion method returns a Venus::Assert object based on the invocant.

Since 1.23

assertion example 1
  # given: synopsis
  package main;
  my $assertion = $example->assertion;
  # bless({name => "Example"}, "Venus::Assert")
    

  checksum() (string)

The checksum method returns an md5 hash string representing the stringified object value (or the object itself).

Since 0.08

checksum example 1
  # given: synopsis;
  my $checksum = $example->checksum;
  # "859a86eed4b2d97eb7b830b02f06de32"
    
checksum example 2
  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"
    

  numified() (number)

The numified method returns the numerical representation of the object which is typically the length (or character count) of the stringified object.

Since 0.08

numified example 1
  # given: synopsis;
  my $numified = $example->numified;
  # 22
    
numified example 2
  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
    

  renew(any @args) (object)

The renew method returns a new instance of the invocant by instantiating the underlying class passing all recognized class attributes to the constructor. Note: This method is not analogous to "clone", i.e. attributes which are references will be passed to the new object as references.

Since 1.23

renew example 1
  # given: synopsis
  package main;
  my $renew = $example->renew;
  # bless({}, "Example")
    
renew example 2
  package Example;
  use Venus::Class;
  base 'Venus::Kind';
  attr 'values';
  package main;
  my $example = Example->new(values => [1,2]);
  my $renew = $example->renew;
  # bless({values => [1,2]}, "Example")
    
renew example 3
  package Example;
  use Venus::Class;
  base 'Venus::Kind';
  attr 'keys';
  attr 'values';
  package main;
  my $example = Example->new(values => [1,2]);
  my $renew = $example->renew(keys => ['a','b']);
  # bless({keys => ["a","b"], values => [1,2]}, "Example")
    

  safe(string | 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.

Since 0.08

safe example 1
  # given: synopsis;
  my $safe = $example->safe('class');
  # "Example"
    
safe example 2
  # given: synopsis;
  my $safe = $example->safe(sub {
    ${_}->class / 2
  });
  # '0'
    
safe example 3
  # given: synopsis;
  my $safe = $example->safe(sub {
    die;
  });
  # undef
    

  self() (any)

The self method returns the invocant.

Since 1.23

self example 1
  # given: synopsis
  package main;
  my $self = $example->self;
  # bless({}, "Example")
    

  stringified() (string)

The stringified method returns the object, stringified (i.e. a dump of the object's value).

Since 0.08

stringified example 1
  # given: synopsis;
  my $stringified = $example->stringified;
  # bless({}, 'Example')
    
stringified example 2
  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(string | 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.

Since 0.08

trap example 1
  # given: synopsis;
  my $result = $example->trap('class');
  # ["Example"]
    
trap example 2
  # given: synopsis;
  my ($results, $warnings, $errors) = $example->trap('class');
  # (["Example"], [], [])
    
trap example 3
  # given: synopsis;
  my $trap = $example->trap(sub {
    ${_}->class / 2
  });
  # ["0"]
    
trap example 4
  # given: synopsis;
  my ($results, $warnings, $errors) = $example->trap(sub {
    ${_}->class / 2
  });
  # (["0"], ["Argument ... isn't numeric in division ..."], [])
    
trap example 5
  # given: synopsis;
  my $trap = $example->trap(sub {
    die;
  });
  # []
    
trap example 6
  # given: synopsis;
  my ($results, $warnings, $errors) = $example->trap(sub {
    die;
  });
  # ([], [], ["Died..."])
    

Awncorp, "awncorp@cpan.org"

Copyright (C) 2022, Awncorp, "awncorp@cpan.org".

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.

2023-11-27 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.