Abstract-Meta-Class
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
Changes
examples/example1.pl
lib/Abstract/Meta/Attribute.pm
lib/Abstract/Meta/Attribute/Method.pm
lib/Abstract/Meta/Class.pm
Makefile.PL
MANIFEST
META.yml Module meta-data (added by MakeMaker)
README
t/meta/array_storage/association.t
t/meta/array_storage/attribute.t
t/meta/array_storage/class.t
t/meta/association.t
t/meta/attribute.t
t/meta/class.t
t/meta/fix.t
t/pod.t
t/pod_coverage.t
lib/Abstract/Meta/Attribute.pm view on Meta::CPAN
Abstract::Meta::Attribute - Meta object attribute.
=head1 SYNOPSIS
use Abstract::Meta::Class ':all';
has '$.attr1' => (default => 0);
=head1 DESCRIPTION
An object that describes an attribute.
It includes required, data type, association validation, default value, lazy retrieval.
Name of attribute must begin with one of the follwoing prefix:
$. => Scalar,
@. => Array,
%. => Hash,
&. => Code,
=head1 EXPORT
None.
lib/Abstract/Meta/Attribute/Method.pm view on Meta::CPAN
my $attr = shift;
my $storage_key = $attr->storage_key;
my $transistent = $attr->transistent;
my $accessor = $attr->accessor;
my $required = $attr->required;
my $default = $attr->default;
my $associated_class = $attr->associated_class;
my $perl_type = $attr->perl_type;
my $index_by = $attr->index_by;
my $on_change = $attr->on_change;
my $data_type_validation = $attr->data_type_validation;
my $on_validate = $attr->on_validate;
my $array_storage_type = $attr->storage_type eq 'Array';
$array_storage_type ?
sub {
my ($self, $value) = @_;
if (! defined $value && defined $default) {
if (ref($default) eq 'CODE') {
$value = $default->($self, $attr);
} else {
$value = $default;
}
}
$on_validate->($self, $attr, 'mutator', \$value) if $on_validate;
if ($data_type_validation) {
$value = index_association_data($value, $accessor, $index_by)
if ($associated_class && $perl_type eq 'Hash');
$attr->validate_data_type($self, $value, $accessor, $associated_class, $perl_type);
if($required) {
if ($perl_type eq 'Hash') {
confess "attribute $accessor is required"
unless scalar %$value;
} elsif ($perl_type eq 'Array') {
confess "attribute $accessor is required"
unless scalar @$value;
}
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.780 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )