| Class-Param documentation | view source | Contained in the Class-Param distribution. |
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;
}
Required.
names => sub {
my ( $self ) = @_;
return keys %hash;
}
Required.
remove => sub {
my ( $self, $name ) = @_;
return delete $hash{ $name };
}
Required.
clear => sub {
my ( $self ) = @_;
return %hash = ();
}
Optional.
count => sub {
my ( $self ) = @_;
return scalar keys %hash;
}
Optional.
has => sub {
my ( $self, $name ) = @_;
return exists $hash{ $name };
}
Optional.
param => sub { }
Optional. See Class::Param::Base for expected behavior.
add => sub { }
Optional. See Class::Param::Base for expected behavior.
scan => sub { }
Optional. See Class::Param::Base for expected behavior.
param => sub { }
Optional. See Class::Param::Base for expected behavior.
Christian Hansen chansen@cpan.org
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| Class-Param documentation | view source | Contained in the Class-Param distribution. |