NAME
Venus::Atom - Atom Class
ABSTRACT
Atom Class for Perl 5
SYNOPSIS
package main;
use Venus::Atom;
my $atom = Venus::Atom->new;
# $atom->get;
# undef
DESCRIPTION
This package provides a write-once object representing a constant value.
INHERITS
This package inherits behaviors from:
METHODS
This package provides the following methods:
get
get() (any)
The get method can be used to get the underlying constant value set during instantiation.
Since 3.55
set
set(any $data) (any)
The set method can be used to set the underlying constant value set during instantiation or via this method. An atom can only be set once, either at instantiation of via this method. Any attempt to re-set the atom will result in an error.
Since 3.55
- set example 2
-
# given: synopsis package main; my $set = $atom->set("hello"); $atom->set("hello"); # Exception! (isa Venus::Atom::Error) (see error_on_set)
ERRORS
This package may raise the following errors:
- error:
error_on_set
-
This package may raise an error_on_set exception.
example 1
# given: synopsis; my $input = { throw => 'error_on_set', value => 'test', }; my $error = $atom->catch('error', $input); # my $name = $error->name; # "on_set" # my $message = $error->render; # "Can't re-set atom value to \"test\"" # my $value = $error->stash('value'); # "test"
OPERATORS
This package overloads the following operators:
- operation:
("")
-
This package overloads the
""
operator.example 1
# given: synopsis; my $result = "$atom"; # ""
example 2
# given: synopsis; $atom->set("hello"); my $result = "$atom"; # "hello"
- operation:
(eq)
-
This package overloads the
eq
operator.example 1
# given: synopsis; my $result = $atom eq ""; # 1
example 2
# given: synopsis; $atom->set("hello"); my $result = $atom eq "hello"; # 1
- operation:
(ne)
-
This package overloads the
ne
operator.example 1
# given: synopsis; my $result = $atom ne ""; # 0
example 2
# given: synopsis; $atom->set("hello"); my $result = $atom ne ""; # 1
- operation:
(qr)
-
This package overloads the
qr
operator.example 1
# given: synopsis; my $test = 'hello' =~ qr/$atom/; # 1
AUTHORS
Awncorp, awncorp@cpan.org
LICENSE
Copyright (C) 2000, 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.