Venus::Role::Optional
Optional Role
Optional Role for Perl 5
method: clear method: has method: reset
package Person;
use Venus::Class;
with 'Venus::Role::Optional';
attr 'fname';
attr 'lname';
attr 'email';
package main;
my $person = Person->new(
fname => 'Elliot',
lname => 'Alderson',
);
# bless({fname => 'Elliot', lname => 'Alderson'}, 'Person')
This package modifies the consuming package and provides methods for automating object construction and attribute accessors.
The clear method deletes an attribute and returns the removed value.
clear(string $name) (any)
{ since => '1.55', }
=example-1 clear
# given: synopsis
package main;
my $fname = $person->clear('fname');
# "Elliot"
The has method returns truthy if the attribute specified exists, otherwise returns falsy.
has(string $name) (boolean)
{ since => '1.55', }
=example-1 has
# given: synopsis
package main;
my $has_fname = $person->has('fname');
# true
The reset method rebuilds an attribute and returns the deleted value.
reset(string $name) (any)
{ since => '1.55', }
=example-1 reset
# given: synopsis
package main;
my $fname = $person->reset('fname');
# "Elliot"
This library provides a mechanism for automatically validating class attributes using Venus::Assert based on the return value of the attribute callback. The callback should be in the form of assert_${name}, and should return a Venus::Assert object or a "validation expression" (string) to be passed to the "expression" in Venus::Assert method.
This library provides a mechanism for automatically building class attributes on construction, and during getting and setting its value, after any default values are processed, based on the return value of the attribute callback. The callback should be in the form of build_${name}, and is passed any arguments provided.
This library provides a mechanism for automatically checking class attributes after getting or setting its value. The callback should be in the form of check_${name}, and is passed any arguments provided.
This library provides a mechanism for automatically coercing class attributes into class instances using Venus::Space based on the return value of the attribute callback. The callback should be in the form of coerce_${name}, and should return the name of the package to be constructed. That package will be instantiated via the customary new method, passing the data recevied as its arguments.
This library provides a mechanism for automatically defaulting class attributes to predefined values, statically or dynamically based on the return value of the attribute callback. The callback should be in the form of default_${name}, and should return the value to be used if no value exists or has been provided to the constructor.
This library provides a mechanism for automatically setting class attributes to predefined values, statically or dynamically based on the return value of the attribute callback. The callback should be in the form of initial_${name}, and should return the value to be used if no value has been provided to the constructor. This behavior is similar to the "defaulting" mechanism but is only executed during object construction.
This library provides a mechanism for automatically building class attributes during getting and setting its value, after any default values are processed, based on the return value of the attribute callback. The callback should be in the form of lazy_build_${name}, and is passed any arguments provided.
This library provides a mechanism for hooking into the class attribute reader (accessor) for reading values via the the attribute reader callback. The callback should be in the form of read_${name}, and should read and return the value for the attribute specified.
This library provides a mechanism for hooking into the class attribute writer (accessor) for writing values via the the attribute writer callback. The callback should be in the form of write_${name}, and should set and return the value for the attribute specified.
This library provides a mechanism for automatically validating class attributes using the attribute callback provided. The author is resposible for validating the state of the attribute and raising an exception when an attribute fails validation. The callback should be in the form of self_assert_${name}.
This library provides a mechanism for automatically coercing class attributes using the attribute callback provided. The author is resposible for any transformations to the attribute and value. The callback should be in the form of self_coerce_${name}.
This library provides a mechanism for automatically triggering routines after reading or writing class attributes via an attribute callback. The callback should be in the form of trigger_${name}, and will be invoked after the related attribute is read or written.
This library provides a mechanism for marking class attributes as "readonly" (or not) based on the return value of the attribute callback. The callback should be in the form of readonly_${name}, and should return truthy to automatically throw an exception if a change is attempted.
This library provides a mechanism for marking class attributes as "readwrite" (or not) based on the return value of the attribute callback. The callback should be in the form of readwrite_${name}, and should return falsy to automatically throw an exception if a change is attempted.
This library provides a mechanism for marking class attributes as "required" (i.e. to be provided to the constructor) based on the return value of the attribute callback. The callback should be in the form of require_${name}, and should return truthy to automatically throw an exception if the related attribute is missing.
t/Venus.t: present: authors t/Venus.t: present: license
68 POD Errors
The following errors were encountered while parsing the POD:
- Around line 18:
Unknown directive: =name
- Around line 26:
Unknown directive: =tagline
- Around line 34:
Unknown directive: =abstract
- Around line 42:
Unknown directive: =includes
- Around line 52:
Unknown directive: =synopsis
- Around line 87:
Unknown directive: =description
- Around line 96:
Unknown directive: =method
- Around line 100:
Unknown directive: =signature
- Around line 104:
Unknown directive: =metadata
- Around line 144:
=cut found outside a pod block. Skipping to next block.
- Around line 167:
=cut found outside a pod block. Skipping to next block.
- Around line 177:
Unknown directive: =method
- Around line 182:
Unknown directive: =signature
- Around line 186:
Unknown directive: =metadata
- Around line 221:
=cut found outside a pod block. Skipping to next block.
- Around line 230:
Unknown directive: =method
- Around line 234:
Unknown directive: =signature
- Around line 238:
Unknown directive: =metadata
- Around line 278:
=cut found outside a pod block. Skipping to next block.
- Around line 305:
=cut found outside a pod block. Skipping to next block.
- Around line 318:
Unknown directive: =feature
- Around line 359:
=cut found outside a pod block. Skipping to next block.
- Around line 407:
=cut found outside a pod block. Skipping to next block.
- Around line 450:
=cut found outside a pod block. Skipping to next block.
- Around line 499:
=cut found outside a pod block. Skipping to next block.
- Around line 526:
Unknown directive: =feature
- Around line 587:
=cut found outside a pod block. Skipping to next block.
- Around line 660:
=cut found outside a pod block. Skipping to next block.
- Around line 720:
=cut found outside a pod block. Skipping to next block.
- Around line 768:
=cut found outside a pod block. Skipping to next block.
- Around line 809:
=cut found outside a pod block. Skipping to next block.
- Around line 824:
Unknown directive: =feature
- Around line 871:
=cut found outside a pod block. Skipping to next block.
- Around line 934:
=cut found outside a pod block. Skipping to next block.
- Around line 956:
Unknown directive: =feature
- Around line 1011:
=cut found outside a pod block. Skipping to next block.
- Around line 1073:
=cut found outside a pod block. Skipping to next block.
- Around line 1123:
=cut found outside a pod block. Skipping to next block.
- Around line 1140:
Unknown directive: =feature
- Around line 1190:
=cut found outside a pod block. Skipping to next block.
- Around line 1215:
Unknown directive: =feature
- Around line 1266:
=cut found outside a pod block. Skipping to next block.
- Around line 1292:
Unknown directive: =feature
- Around line 1328:
=cut found outside a pod block. Skipping to next block.
- Around line 1374:
=cut found outside a pod block. Skipping to next block.
- Around line 1420:
=cut found outside a pod block. Skipping to next block.
- Around line 1435:
Unknown directive: =feature
- Around line 1487:
=cut found outside a pod block. Skipping to next block.
- Around line 1507:
Unknown directive: =feature
- Around line 1556:
=cut found outside a pod block. Skipping to next block.
- Around line 1579:
Unknown directive: =feature
- Around line 1624:
=cut found outside a pod block. Skipping to next block.
- Around line 1681:
=cut found outside a pod block. Skipping to next block.
- Around line 1739:
=cut found outside a pod block. Skipping to next block.
- Around line 1762:
Unknown directive: =feature
- Around line 1812:
=cut found outside a pod block. Skipping to next block.
- Around line 1863:
=cut found outside a pod block. Skipping to next block.
- Around line 1880:
Unknown directive: =feature
- Around line 1939:
=cut found outside a pod block. Skipping to next block.
- Around line 1968:
Unknown directive: =feature
- Around line 2020:
=cut found outside a pod block. Skipping to next block.
- Around line 2036:
Unknown directive: =feature
- Around line 2088:
=cut found outside a pod block. Skipping to next block.
- Around line 2104:
Unknown directive: =feature
- Around line 2155:
=cut found outside a pod block. Skipping to next block.
- Around line 2212:
=cut found outside a pod block. Skipping to next block.
- Around line 2266:
=cut found outside a pod block. Skipping to next block.
- Around line 2282:
Unknown directive: =partials