has moon => ro, isa(hash(a => "b", c => "d", e => [qw/1 2 3/], f => { 1 => { 2 => { 3 => 4 } } })), lazy, build_order(3);
has stars => rw, isa(array(qw/a b c d/)), lazy, build_order(3);
has satellites => rw, isa(integer), lazy, build_order(2);
has mind => rw, isa(ordered_hash(
chang => 1,
zante => 2,
oistins => 3
)), lazy, build_order(1);
has [qw/look up/] => isa(string), delay, coerce(sub {
my $followed = [qw/moon starts satellites/]->[int(rand(3))];
$_[0]->$followed;
});
has clouds => isa(
typed_hash(
[
strict => 1,
required => [qw/a b c/],
keys => [
moon => Int,
stars => Str,
satellites => typed_hash([keys => [ mind => Str ]], %{$_[0]})
],
],
moon => 211,
stars => 'test'
satellites => { custom => 'after', mind => 'abc', },
)
);
1;
...
Synopsis->new( satellites => 5 );
$synopsis->mind->{oistins};
...
package Life;
extends 'Synopsis';
requires_has qw/moon stars satellites mind/
1;
=cut
=head1 keywords
The following keywords are exported automatically when you declare the use of YAOO.
=cut
=head2 has
Declare an attribute/accessor.
has one => ro, isa(object);
=cut
=head2 ro
Set the attribute to read only, so it can only be set on instantiation of the YAOO object.
has two => ro;
=cut
=head2 rw
Set the attribute tp read write, so it can be set at any time. This is the default if you do not provide ro or rw when declaring your attribute.
has three => rw;
=cut
=head2 isa
Declare a type for the attribute, see the types below for all the current valid options.
has four => isa(any($default_value));
=cut
=head3 any
Allow any value to be set for the attribute.
has five => isa(any);
=cut
=head3 string
Allow only string values to be set for the attribute.
has six => isa(string);
=cut
=head3 scalarref
Allow only scalar references to be set for the attribute.
has seven => isa(scalarref);
=cut
=head3 integer
Allow only integer values to be be set for the attribute.
has eight => isa(integer(10));
=cut
=head3 float
Allow only floats to be set for the attribute.
has nine => isa(float(211.11));
=cut
=head3 boolean
Allow only boolean values to be set for the attribute.
has ten => isa(boolean(\1));
=cut
=head3 ordered_hash
Allow only hash values to be set for the attribute, this will also assist with declaring a ordered hash which has a predicatable order for the keys based upon how it is defined.
has eleven => isa(ordered_hash( one => 1, two => 2, three => 3 ));
=cut
=head3 hash
Allow only hash values to be set for the attribute.
has twelve => isa(hash);
=cut
=head3 array
Allow only array values to be set for the attribute.
has thirteen => isa(array);
=cut
=head3 object
Allow any object to be set for the attribute.
has fourteen => isa(object);
=cut
=head3 fh
Allow any file handle to be set for the attribute
has fifthteen => isa(fh);
=cut
=head2 default
Set the default value for the attribute, this can also be done by passing in the isa type.
has sixteen => isa(string), default('abc');
=cut
=head2 coerce
Define a coerce sub routine so that you can manipulate the passed value when ever it is set.
has seventeen => isa(object(1)), coerce(sub {
JSON->new();
});
=cut
=head2 required
Define a required sub routing so that you can dynamically check for required keys/values for the given attribute.
has eighteen => isa(hash) required(sub {
die "the world is a terrible place" if not $_[1]->{honesty};
});
=cut
=head2 trigger
Define a trigger sub which is called after the attribute has been set..
has nineteen => isa(hash) trigger(sub {
$_[0]->no_consent;
});
=cut
=head2 lazy
Make the attribute lazy so that it is instantiated early.
has twenty => isa(string('Foo::Bar')), lazy;
=cut
=head2 delay
Make the attribute delayed so that it is instantiated late.
has twenty_one => isa(object), delay, coerce(sub { $_[0]->twenty->new });
=cut
=head2 build_order
Configure a build order for the attributes, this allows you to control the order in which they are 'set'.
has twenty_two => isa(string), build_order(18);
=cut
=head2 extends
Declare inheritance.
extends 'Moonlight';
=cut
=head2 requires_has
Decalre attributes that must exist in the inheritance of the object.
require_has qw/one two three/
=cut
=head2 requires_sub
Declare sub routines/methods that must exist in the inheritance of the object.
require_sub qw/transparency dishonesty/
=cut
=head1 AUTHOR
LNATION, C<< <email at lnation.org> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-yaoo at rt.cpan.org>, or through