In perl a particular namespace can be used for different things. From simply to collect a bunch of variables and subroutines, to implement a complete class, or can act as a class "broker" when its static methods are constructors for other classes. The ways in which you can use
The value returned by "add" in JSPL::Controller and
Stash instances entering perl land are wrapped as
my $ctl = $ctx->get_controller; my $stash = $ctl->add('DBI'); # Expose to js the package 'DBI'.
- allow_from_js ( [ BOOLEAN ] )
my $old = $stash->allow_from_js($bool);
# Expose the namespace 'ForJSUse' my $stash = $ctl->add('ForJSuse'); # Make 'ForJSUse' modifiable by js code $stash->allow_from_js(1);
- class_bind ( BIND_POINT )
require 'DBI'; $ctl->add('DBI')->class_bind('DBI');
Exposes the perl package 'DBI' and binds it to the property of the same name as a class, allowing to call its methods as static ones.
- package_bind ( BIND_POINT )
require 'POSIX'; $ctl->add('POSIX')->package_bind('POSIX');
- set_constructor ( )
- set_constructor ( CODE )
- set_constructor ( SUB_NAME )