added some documentation
[catagits/CatalystX-HelpText.git] / lib / CatalystX / HelpText / Model.pm
CommitLineData
f22d4e6f 1package CatalystX::HelpText::Model;
2use Moose;
3use MooseX::Types::Moose qw/Str Undef/;
4use MooseX::Types::Path::Class qw/ Dir /;
5use Moose::Autobox;
6use Carp qw/ croak confess/;
7use namespace::autoclean;
8
9extends 'Catalyst::Model';
10
11has help_files_path => (
12 is => 'ro',
13 isa => Dir,
14 coerce => 1,
15 required => 1,
16 handles => {
17 _get_file => 'file',
18 }
19);
20
21has help_files_ext => (
22 is => 'ro',
23 isa => Str|Undef,
24 default => 'html',
25);
26
27sub get_help_text_for {
28 my ($self, $help_key) = @_;
29 confess('No $help_key provided') unless $help_key;
30
31 my $fn = $help_key;
32 $fn .= "." . $self->help_files_ext if defined($self->help_files_ext);
33
34 my $file = $self->_get_file($fn);
35
36 return $file->slurp if ( -e $file );
37
38 croak "Cannot find help text '$help_key' in $file";
39}
40
411;
42