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::Value(3) User Contributed Perl Documentation Venus::Kind::Value(3)

Venus::Kind::Value - Value Base Class

Value Base Class for Perl 5

  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.

This package inherits behaviors from:

Venus::Kind

This package integrates behaviors from:

Venus::Role::Accessible

Venus::Role::Buildable

Venus::Role::Explainable

Venus::Role::Pluggable

Venus::Role::Proxyable

Venus::Role::Valuable

This package provides the following methods:

  cast(string $kind) (object | undef)

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.

Since 0.08

cast example 1
  package main;
  my $example = Example->new;
  my $cast = $example->cast;
  # bless({value => undef}, "Venus::Undef")
    
cast example 2
  package main;
  my $example = Example->new(
    value => 123.45,
  );
  my $cast = $example->cast('array');
  # bless({value => [123.45]}, "Venus::Array")
    
cast example 3
  package main;
  my $example = Example->new(
    value => 123.45,
  );
  my $cast = $example->cast('hash');
  # bless({value => {'123.45' => 123.45}, "Venus::Hash")
    

  defined() (number)

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

Since 0.01

defined example 1
  package main;
  my $example = Example->new;
  my $defined = $example->defined;
  # 0
    
defined example 2
  package main;
  my $example = Example->new(time);
  my $defined = $example->defined;
  # 1
    

  explain() (any)

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

Since 0.01

explain example 1
  package main;
  my $example = Example->new('hello, there');
  my $explain = $example->explain;
  # "hello, there"
    

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

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.

Since 1.23

mutate example 1
  # given: synopsis
  package main;
  $example->mutate('test');
  $example;
  # bless({value => 2}, "Example")
    

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.