Class::Param::Callback - Param instance with callbacks
%store = (); $param = Class::Param::Callback->new( get => sub { return $store{ $_[1] } }, set => sub { return $store{ $_[1] } = $_[2] }, has => sub { return exists $store{ $_[1] } }, names => sub { return keys %store }, remove => sub { return delete $store{ $_[1] } } );
Construct a params instance using callbacks.
This method takes a hash of parameters. The following options are valid:
get => sub { my ( $self, $name ) = @_; return $hash{ $name }; }
Required.
set => sub { my ( $self, $name, $value ) = @_; return $hash{ $name } = $value; }
names => sub { my ( $self ) = @_; return keys %hash; }
remove => sub { my ( $self, $name ) = @_; return delete $hash{ $name }; }
clear => sub { my ( $self ) = @_; return %hash = (); }
Optional.
count => sub { my ( $self ) = @_; return scalar keys %hash; }
has => sub { my ( $self, $name ) = @_; return exists $hash{ $name }; }
param => sub { }
Optional. See Class::Param::Base for expected behavior.
add => sub { }
scan => sub { }
Class::Param.
Christian Hansen chansen@cpan.org
chansen@cpan.org
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install Class::Param, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Param
CPAN shell
perl -MCPAN -e shell install Class::Param
For more information on module installation, please visit the detailed CPAN module installation guide.