Aion
view release on metacpan or search on metacpan
lib/Aion/Meta/Feature.pm view on Meta::CPAN
}
my $accessor = $self->construct->accessor;
eval $accessor;
die if $@;
if($self->{make_reader}) {
my $reader = $self->construct->reader;
eval $reader;
die if $@;
}
if($self->{make_writer}) {
my $writer = $self->construct->writer;
eval $writer;
die if $@;
}
if($self->{make_predicate}) {
my $predicate = $self->construct->predicate;
eval $predicate;
die if $@;
}
if($self->{make_clearer}) {
my $clearer = $self->construct->clearer;
eval $clearer;
die if $@;
}
}
# ÐÑедÑÑавление ÑÐµÐ±Ñ Ð² коде
sub meta {
my ($self) = @_;
$self->{meta} //= do {
my ($cls, $name) = @$self{qw/pkg name/};
"\$Aion::META{'$cls'}{feature}{$name}"
};
}
# ÐоÑÑÑп к ÑÑаÑÑ Ñо ÑвойÑÑвами
sub stash {
my ($self, $key, $val) = @_;
my $stash = $self->{stash}{scalar caller} //= {};
@_ > 2? do { $stash->{$key} = $val; $self }: $stash->{$key};
}
# СÑÐ°Ð²Ð½Ð¸Ð²Ð°ÐµÑ ÑÑаÑÑÑ ÑиÑÑ Ñ Ð¿ÐµÑезагÑÑжаемой
sub compare {
my ($self, $other) = @_;
die "Types mismatch: $other->{isa} <=> $self->{isa}" if $self->{isa} && $self->{isa} ne $other->{isa};
}
1;
__END__
=encoding utf-8
=head1 NAME
Aion::Meta::Feature - feature metadescriptor
=head1 SYNOPSIS
use Aion::Meta::Feature;
our $feature = Aion::Meta::Feature->new("My::Package", "my_feature" => (is => 'rw'));
$feature->stringify # => has my_feature => (is => 'rw') of My::Package
=head1 DESCRIPTION
Describes a feature that is added to the class by the C<has> function.
=head1 METHODS
=head2 pkg
ÐакеÑ, к коÑоÑÐ¾Ð¼Ñ Ð¾ÑноÑиÑÑÑ ÑиÑа.
$::feature->pkg # -> "My::Package"
=head2 name
Feature name.
$::feature->name # -> "my_feature"
=head2 opt
Feature options hash.
$::feature->opt # --> {is => 'rw'}
=head2 has
An array of feature options in the form of key-value pairs.
$::feature->has # --> ['is', 'rw']
=head2 construct
Feature constructor object.
ref $::feature->construct # \> Aion::Meta::FeatureConstruct
=head2 order()
The serial number of the feature in the class.
$::feature->order # -> 0
=head2 required (;$bool)
Flag for requiring a feature in the constructor (C<new>).
$::feature->required(1);
( run in 1.157 second using v1.01-cache-2.11-cpan-f56aa216473 )