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:

Venus::Sealed

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

get example 1
# given: synopsis

package main;

my $get = $atom->get;

# undef
get example 2
# given: synopsis

package main;

$atom->set("hello");

my $get = $atom->get;

# "hello"

new

new(any @args) (Venus::Atom)

The new method constructs an instance of the package.

Since 4.15

new example 1
package main;

use Venus::Atom;

my $new = Venus::Atom->new;

# bless(..., "Venus::Atom")
new example 2
package main;

use Venus::Atom;

my $new = Venus::Atom->new('Important');

# bless(..., "Venus::Atom")
new example 3
package main;

use Venus::Atom;

my $new = Venus::Atom->new(value => 'Important');

# bless(..., "Venus::Atom")

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 1
# given: synopsis

package main;

my $set = $atom->set("hello");

# "hello"
may raise Venus::Atom::Error on.set
# given: synopsis

package main;

my $set = $atom->set("hello");

$atom->set("hello");

# Error! (on.set)

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) 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.