NAME
Venus::Sealed - Sealed Class
ABSTRACT
Sealed Class for Perl 5
SYNOPSIS
package main;
use Venus::Sealed;
my $sealed = Venus::Sealed->new('012345');
# $sealed->get;
# '012345'
DESCRIPTION
This package provides a mechanism for sealing object and restricting and/or preventing access to the underlying data structures. This package can be used directly but is meant to be subclassed.
INTEGRATES
This package integrates behaviors from:
METHODS
This package provides the following methods:
get
get(any @args) (any)
The get method can be used directly to get the sealed value set during instantiation, but is meant to be overridden in a subclass to further control access to the underlying data.
Since 3.55
- get example 2
-
package Example; use Venus::Class; base 'Venus::Sealed'; sub __get { my ($self, $init, $data) = @_; return $data->{value}; } sub __set { my ($self, $init, $data, $value) = @_; return $data->{value} = $value; } package main; my $sealed = Example->new("012345"); my $get = $sealed->get; # "012345"
set
set(any @args) (any)
The set method can be used directly to set the sealed value set during instantiation, but is meant to be overridden in a subclass to further control access to the underlying data.
Since 3.55
- set example 2
-
package Example; use Venus::Class; base 'Venus::Sealed'; sub __get { my ($self, $init, $data) = @_; return $data->{value}; } sub __set { my ($self, $init, $data, $value) = @_; return $data->{value} = $value; } package main; my $sealed = Example->new("012345"); my $set = $sealed->set("098765"); # "098765"
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.