=head1 VERSION
-Version 0.01
+Version 0.02
=cut
-our $VERSION = '0.01';
+our $VERSION = '0.02';
-use List::Util ();
+use Scalar::Util ();
+use List::Util ();
use LaTeX::TikZ::Mod::Formatted;
+use LaTeX::TikZ::Interface;
+
use Any::Moose;
use Any::Moose 'Util::TypeConstraints';
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Mod> role, and as such implements the L</tag>, L</covers>, L</declare> and L</apply> methods.
+
+=cut
+
with 'LaTeX::TikZ::Mod';
+=head1 ATTRIBUTES
+
+=head2 C<name>
+
+=cut
+
has 'name' => (
is => 'ro',
isa => 'Str',
required => 1,
);
+=head2 C<above>
+
+=cut
+
subtype 'LaTeX::TikZ::Mod::LevelList'
=> as 'ArrayRef[LaTeX::TikZ::Mod::Layer]';
sub above { @{$_[0]->_above} }
+=head2 C<below>
+
+=cut
+
has '_below' => (
is => 'ro',
isa => 'LaTeX::TikZ::Mod::LevelList',
builder => '_build_score',
);
+=head1 METHODS
+
+=cut
+
my %layers;
around 'new' => sub {
sub BUILD {
my ($self) = @_;
- $layers{$self->name} = $self;
+ my $name = $self->name;
+ $layers{$name} = $self;
+ Scalar::Util::weaken($layers{$name});
}
sub DEMOLISH {
delete $layers{$self->name};
}
+=head2 C<tag>
+
+=cut
+
sub tag {
my ($self) = @_;
ref($self) . '/' . $self->name;
}
-sub cover { $_[0]->name eq $_[1]->name }
+=head2 C<covers>
+
+=cut
+
+sub covers { $_[0]->name eq $_[1]->name }
+
+=head2 C<score>
+
+=cut
{
our %score;
$score{$name}
}
+=head2 C<declare>
+
+=cut
+
sub declare {
shift;
}
}
+=head2 C<apply>
+
+=cut
+
sub apply {
my ($self) = @_;
)
}
-use LaTeX::TikZ::Interface layer => sub {
- shift;
+LaTeX::TikZ::Interface->register(
+ layer => sub {
+ shift;
- my $name = shift;
- __PACKAGE__->new(name => $name, @_);
-};
+ my $name = shift;
+ __PACKAGE__->new(name => $name, @_);
+ },
+);
__PACKAGE__->meta->make_immutable(
inline_constructor => 0,
);
+=head1 SEE ALSO
+
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Mod>.
+
=head1 AUTHOR
Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.