Data::Object::Export
Data-Object Keyword Functions
use Data::Object::Export; my $num = cast 123; # Data::Object::Number my $str = cast 123, 'string'; # Data::Object::String
This package is an exporter that provides a few simple keyword functions to every calling package.
This package can export the following functions.
use Data::Object::Export ':all';
The all export tag will export the exportable functions, i.e. cast, const, do, is_false, is_true, false, true, and raise.
cast
const
do
is_false
is_true
false
true
raise
This package inherits behaviors from:
Exporter
This package implements the following functions.
cast(Any $arg1, Str $type) : Any
The cast function returns a data object for the argument provided. If the data passed is blessed then that same object will be returned.
# given 123 my $num = cast(123); # Data::Object::Number my $str = cast(123, 'string'); # Data::Object::String
do(Str $arg1, Any @args) : Any
The do function is a special constructor function that is automatically exported into the consuming package. It overloads and extends the core "do" in perlfunc function, supporting the core functionality and adding a new feature, and exists to dispatch to exportable Data-Object functions and other dispatchers.
# given file syntax do 'file.pl' # given block syntax do { @{"${class}::ISA"} } # given func-args syntax do('array', [1..4]); # Data::Object::Array
dump(Any $value) : Str
The dump function uses Data::Dumper to return a string representation of the argument provided. This function is not exported but can be access via the super-do function.
# given $value my $str = do('dump', $value);
false() : BooleanObject
The false function returns a falsy boolean object.
my $false = false;
is_false(Any $arg) : BooleanObject
The is_false function with no argument returns a falsy boolean object, otherwise, returns a boolean object based on the value of the argument provided.
my $bool; $bool = is_false; # false $bool = is_false 1; # false $bool = is_false {}; # false $bool = is_false bless {}; # false $bool = is_false 0; # true $bool = is_false ''; # true $bool = is_false undef; # true
is_true(Any $arg) : BooleanObject
The is_true function with no argument returns a truthy boolean object, otherwise, returns a boolean object based on the value of the argument provided.
my $bool; $bool = is_true; # true $bool = is_true 1; # true $bool = is_true {}; # true $bool = is_true bless {}; # true $bool = is_true 0; # false $bool = is_true ''; # false $bool = is_true undef; # false
keyraise(Str $message, Any $context, Num $offset) : ()
The keyraise function is used internally by function keywords to "raise" exceptions from the persepective of the caller and not the keyword itself.
keyraise($message, $context, $offset);
load(Str $arg1) : ClassName
The load function attempts to dynamically load a module and either raises an exception or returns the package name of the loaded module. This function is not exported but can be access via the super-do function.
# given 'List::Util'; $package = do('load', 'List::Util'); # List::Util
raise(Any @args) : Object
The raise function will dynamically load and raise an exception object. This function takes all arguments accepted by the Data::Object::Exception class.
# given $message; raise $message; # Exception! thrown in -e at line 1
true() : BooleanObject
The true function returns a truthy boolean object.
my $true = true;
Al Newkirk, +309
+309
Anthony Brummett, +10
+10
Adam Hopkins, +2
+2
José Joaquín Atria, +1
+1
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To get the most out of this distribution, consider reading the following:
Do
Data::Object
Data::Object::Class
Data::Object::ClassHas
Data::Object::Role
Data::Object::RoleHas
Data::Object::Library
To install Do, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Do
CPAN shell
perl -MCPAN -e shell install Do
For more information on module installation, please visit the detailed CPAN module installation guide.