Aion
view release on metacpan or search on metacpan
* `ro` â ÑоздаÑÑ ÑолÑко геÑÑеÑ.
* `wo` â ÑоздаÑÑ ÑолÑко ÑеÑÑеÑ.
* `rw` â ÑоздаÑÑ Ð³ÐµÑÑÐµÑ Ð¸ ÑеÑÑеÑ.
Ðо ÑмолÑÐ°Ð½Ð¸Ñ â `rw`.
ÐополниÑелÑнÑе ÑазÑеÑениÑ:
* `+` â ÑиÑа обÑзаÑелÑна в паÑамеÑÑаÑ
конÑÑÑÑкÑоÑа. `+` не иÑполÑзÑеÑÑÑ Ñ `-`.
* `-` â ÑиÑа не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ ÑÑÑановлена ÑеÑез конÑÑÑÑкÑоÑ. '-' не иÑполÑзÑеÑÑÑ Ñ `+`.
* `*` â не инкÑеменÑиÑоваÑÑ ÑÑÑÑÑик ÑÑÑлок на знаÑение (пÑимениÑÑ `weaken` к знаÑÐµÐ½Ð¸Ñ Ð¿Ð¾Ñле ÑÑÑановки его в ÑиÑÑ).
```perl
package ExIs { use Aion;
has rw => (is => 'rw');
has ro => (is => 'ro+');
has wo => (is => 'wo-');
}
eval { ExIs->new }; $@ # ~> \* Feature ro is required!
eval { ExIs->new(ro => 10, wo => -10) }; $@ # ~> \* Feature wo cannot set in new!
i18n/Aion.ru-en.po view on Meta::CPAN
msgid "Ðо ÑмолÑÐ°Ð½Ð¸Ñ â `rw`."
msgstr "By default - `rw`."
msgid "ÐополниÑелÑнÑе ÑазÑеÑениÑ:"
msgstr "Additional permits:"
msgid ""
"* `+` â ÑиÑа обÑзаÑелÑна в паÑамеÑÑаÑ
конÑÑÑÑкÑоÑа. `+` не иÑполÑзÑеÑÑÑ Ñ `-`.\n"
"* `-` â ÑиÑа не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ ÑÑÑановлена ÑеÑез конÑÑÑÑкÑоÑ. '-' не иÑполÑзÑеÑÑÑ Ñ `+`.\n"
"* `*` â не инкÑеменÑиÑоваÑÑ ÑÑÑÑÑик ÑÑÑлок на знаÑение (пÑимениÑÑ `weaken` к знаÑÐµÐ½Ð¸Ñ Ð¿Ð¾Ñле ÑÑÑановки его в ÑиÑÑ)."
msgstr ""
"* `+` - feature is required in the parameters of the designer. `+` is not used with `-`.\n"
"* `-` - a feature cannot be installed through the constructor. '-' is not used with `+`.\n"
"* `*` - do not increase the counter of links to the value (apply `weaken` to the value after installing it in a feature)."
msgid "ФÑнкÑÐ¸Ñ Ñ `*` не ÑдеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð·Ð½Ð°Ñение:"
msgstr "The function with `*` does not hold the meaning:"
msgid "УказÑÐ²Ð°ÐµÑ Ñип, а ÑоÑнее â валидаÑоÑ, ÑиÑи."
msgstr "Indicates the type, or rather - a validator, feature."
msgid "СпиÑок валидаÑоÑов Ñм. в [Aion::Type](https://metacpan.org/pod/Aion::Type)."
msgstr "For a list of validators, see [Aion::Type](https://metacpan.org/pod/Aion:::Type)."
lib/Aion.md view on Meta::CPAN
* `ro` â ÑоздаÑÑ ÑолÑко геÑÑеÑ.
* `wo` â ÑоздаÑÑ ÑолÑко ÑеÑÑеÑ.
* `rw` â ÑоздаÑÑ Ð³ÐµÑÑÐµÑ Ð¸ ÑеÑÑеÑ.
Ðо ÑмолÑÐ°Ð½Ð¸Ñ â `rw`.
ÐополниÑелÑнÑе ÑазÑеÑениÑ:
* `+` â ÑиÑа обÑзаÑелÑна в паÑамеÑÑаÑ
конÑÑÑÑкÑоÑа. `+` не иÑполÑзÑеÑÑÑ Ñ `-`.
* `-` â ÑиÑа не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ ÑÑÑановлена ÑеÑез конÑÑÑÑкÑоÑ. '-' не иÑполÑзÑеÑÑÑ Ñ `+`.
* `*` â не инкÑеменÑиÑоваÑÑ ÑÑÑÑÑик ÑÑÑлок на знаÑение (пÑимениÑÑ `weaken` к знаÑÐµÐ½Ð¸Ñ Ð¿Ð¾Ñле ÑÑÑановки его в ÑиÑÑ).
```perl
package ExIs { use Aion;
has rw => (is => 'rw');
has ro => (is => 'ro+');
has wo => (is => 'wo-');
}
eval { ExIs->new }; $@ # ~> \* Feature ro is required!
eval { ExIs->new(ro => 10, wo => -10) }; $@ # ~> \* Feature wo cannot set in new!
lib/Aion.pm view on Meta::CPAN
package Aion;
use 5.22.0;
no strict; no warnings; no diagnostics;
use common::sense;
our $VERSION = "0.4";
use Scalar::Util qw/blessed weaken/;
use Aion::Types qw//;
# Ðогда оÑÑÑеÑÑвлÑÑÑ Ð¿ÑовеÑки:
# ro - ÑолÑко пÑи вÑдаÑе
# wo - ÑолÑко пÑи ÑÑÑановке
# rw - пÑи вÑдаÑе и ÑcÑановке
# no - никогда не пÑовеÑÑÑÑ
use config ISA => 'rw';
sub export($@);
lib/Aion.pm view on Meta::CPAN
}
# ÐкÑпоÑÑиÑÑÐµÑ ÑÑнкÑии в пакеÑ, еÑли иÑ
Ñам еÑÑ Ð½ÐµÑ
sub is_aion($) {
my $pkg = shift;
die "$pkg is'nt class of Aion!" if !exists $META{$pkg};
}
#@category Aspects
sub _weaken_init {
my ($self, $feature) = @_;
weaken $self->{$feature->{name}};
}
# ro, rw, + и -, *
sub is_aspect {
my ($cls, $name, $is, $construct, $feature) = @_;
die "Use is => '(ro|rw|wo|no)[+-]?[*]?'" if $is !~ /^(ro|rw|wo|no)[+-]?[*]?\z/;
$construct->{get} = "die 'has: $name is $is (not get)'" if $is =~ /^(wo|no)/;
if($is =~ /^(ro|no)/) {
$construct->{set} = "die 'has: $name is $is (not set)'";
}
elsif($is =~ /\*\z/) {
$construct->{ret} = "; Scalar::Util::weaken(\$self->{$name})$construct->{ret}";
}
$feature->{required} = 1 if $is =~ /\+/;
$feature->{excessive} = 1 if $is =~ /-/;
push @{$feature->{init}}, \&_weaken_init if $is =~ /\*\z/;
}
# isa => Type
sub isa_aspect {
my ($cls, $name, $isa, $construct, $feature) = @_;
die "has: $name - isa maybe Aion::Type"
if !UNIVERSAL::isa($isa, 'Aion::Type');
$feature->{isa} = $isa;
lib/Aion.pm view on Meta::CPAN
By default - C<rw>.
Additional permits:
=over
=item * C<+> - feature is required in the parameters of the designer. C<+> is not used with C<->.
=item * C<-> - a feature cannot be installed through the constructor. '-' is not used with C<+>.
=item * C<*> - do not increase the counter of links to the value (apply C<weaken> to the value after installing it in a feature).
=back
package ExIs { use Aion;
has rw => (is => 'rw');
has ro => (is => 'ro+');
has wo => (is => 'wo-');
}
eval { ExIs->new }; $@ # ~> \* Feature ro is required!
# * `ro` â ÑоздаÑÑ ÑолÑко геÑÑеÑ.
# * `wo` â ÑоздаÑÑ ÑолÑко ÑеÑÑеÑ.
# * `rw` â ÑоздаÑÑ Ð³ÐµÑÑÐµÑ Ð¸ ÑеÑÑеÑ.
#
# Ðо ÑмолÑÐ°Ð½Ð¸Ñ â `rw`.
#
# ÐополниÑелÑнÑе ÑазÑеÑениÑ:
#
# * `+` â ÑиÑа обÑзаÑелÑна в паÑамеÑÑаÑ
конÑÑÑÑкÑоÑа. `+` не иÑполÑзÑеÑÑÑ Ñ `-`.
# * `-` â ÑиÑа не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ ÑÑÑановлена ÑеÑез конÑÑÑÑкÑоÑ. '-' не иÑполÑзÑеÑÑÑ Ñ `+`.
# * `*` â не инкÑеменÑиÑоваÑÑ ÑÑÑÑÑик ÑÑÑлок на знаÑение (пÑимениÑÑ `weaken` к знаÑÐµÐ½Ð¸Ñ Ð¿Ð¾Ñле ÑÑÑановки его в ÑиÑÑ).
#
done_testing; }; subtest 'is => $permissions' => sub {
package ExIs { use Aion;
has rw => (is => 'rw');
has ro => (is => 'ro+');
has wo => (is => 'wo-');
}
::like scalar do {eval { ExIs->new }; $@}, qr!\* Feature ro is required\!!, 'eval { ExIs->new }; $@ # ~> \* Feature ro is required!';
::like scalar do {eval { ExIs->new(ro => 10, wo => -10) }; $@}, qr!\* Feature wo cannot set in new\!!, 'eval { ExIs->new(ro => 10, wo => -10) }; $@ # ~> \* Feature wo cannot set in new!';
( run in 1.416 second using v1.01-cache-2.11-cpan-65fba6d93b7 )