Permalink
Browse files

"final" docs

  • Loading branch information...
1 parent ac74da7 commit b3750007ae8265b475af38e93469b9816659d6ea @rjbs committed Aug 8, 2009
Showing with 75 additions and 2 deletions.
  1. +20 −1 lib/Path/Resolver/Role/Converter.pm
  2. +16 −0 lib/Path/Resolver/Role/FileResolver.pm
  3. +39 −1 lib/Path/Resolver/SimpleEntity.pm
@@ -4,8 +4,27 @@ use Moose::Role;
use namespace::autoclean;
+=head1 IMPLEMENTING
+
+Classes implementing the Converter role must provide three methods:
+
+=method input_type
+
+This method must return the type of input that's expected.
+
+=method output_type
+
+This method must return the type of input that's promised to be returned.
+
+=method convert
+
+This method performs the actual converstion. It's passed an object of
+C<input_type> and returns an object of C<output_type>.
+
+=cut
+
requires 'input_type';
-requires 'convert';
requires 'output_type';
+requires 'convert';
1;
@@ -11,6 +11,22 @@ use Path::Resolver::CustomConverter;
use MooseX::Types;
+=head1 SYNOPSIS
+
+The FileResolver role is a specialized form of the Resolver role, and can be
+used in its place. (Anything that does the FileResolver role automatically
+does the Resolver role, too.)
+
+FileResolver classes have a native type of Path::Resolver::Types::AbsFilePath
+(from L<Path::Resolver::Types>). Basically, they will natively return a
+Path::Class::File pointing to an absolute file path.
+
+FileResolver classes also have a default converter that will convert the
+AbsFilePath to a L<Path::Resolver::SimpleEntity>, meaning that by default a
+FileResolver's C<entity_at> will return a SimpleEntity.
+
+=cut
+
sub native_type { AbsFilePath }
my $converter = Path::Resolver::CustomConverter->new({
@@ -2,8 +2,46 @@ package Path::Resolver::SimpleEntity;
# ABSTRACT: a dead-simple entity to return, only provides content
use Moose;
+use MooseX::Types::Moose qw(ScalarRef);
+
use namespace::autoclean;
-has content_ref => (is => 'ro');
+=head1 SYNOPSIS
+
+ my $entity = Path::Resolver::SimpleEntity->new({
+ content_ref => \$string,
+ });
+
+ printf "Content: %s\n", $entity->content;
+
+This class is used as an extremely simple way to represent hunks of stringy
+content.
+
+=attr content_ref
+
+This is the only real attribute of a SimpleEntity. It's a reference to a
+string that is the content of the entity.
+
+=cut
+
+has content_ref => (is => 'ro', isa => ScalarRef, required => 1);
+
+=method content
+
+This method returns the dereferenced content from the C<content_ref> attribuet.
+
+=cut
+
+sub content { return ${ $_[0]->content_ref } }
+
+=method length
+
+This method returns the length of the content.
+
+=cut
+
+sub length {
+ length ${ $_[0]->content_ref }
+}
1;

0 comments on commit b375000

Please sign in to comment.