package WWW::NOS::Open::Document; # -*- cperl; cperl-indent-level: 4 -*-
use strict;
use warnings;
# $Id: Document.pm 414 2011-01-13 22:43:18Z roland $
# $Revision: 414 $
# $HeadURL: svn+ssh://ipenburg.xs4all.nl/srv/svnroot/candi/trunk/WWW-NOS-Open/lib/WWW/NOS/Open/Document.pm $
# $Date: 2011-01-13 23:43:18 +0100 (Thu, 13 Jan 2011) $
use utf8;
use 5.006000;
our $VERSION = '0.02';
use Moose qw/has/;
use Moose::Util::TypeConstraints qw/enum/;
use namespace::autoclean -also => qr/^__/sxm;
use WWW::NOS::Open::TypeDef qw(NOSDateTime NOSURI);
use Readonly;
Readonly::Scalar my $UNDER => q{_};
Readonly::Scalar my $GETTER => q{get};
Readonly::Array my @CATEGORIES => qw(Nieuws Sport);
Readonly::Array my @RESOURCE_TYPES => qw(artikel article video audio);
has '_id' => (
is => 'ro',
isa => 'Str',
reader => 'get_id',
init_arg => 'id',
);
has '_score' => (
is => 'ro',
isa => 'Num',
reader => 'get_score',
init_arg => 'score',
);
has '_type' => (
is => 'ro',
isa => enum( [@RESOURCE_TYPES] ),
reader => $GETTER . $UNDER . 'type',
init_arg => 'type',
);
my @strings = qw(title description subcategory);
while ( my $string = shift @strings ) {
has $UNDER
. $string => (
is => 'ro',
isa => 'Str',
reader => $GETTER . $UNDER . $string,
init_arg => $string,
);
}
my @dates = qw(published last_update);
while ( my $date = shift @dates ) {
has $UNDER
. $date => (
is => 'ro',
isa => NOSDateTime,
coerce => 1,
reader => $GETTER . $UNDER . $date,
init_arg => $date,
);
}
my @uris = qw(thumbnail link);
while ( my $uri = shift @uris ) {
has $UNDER
. $uri => (
is => 'ro',
isa => NOSURI,
coerce => 1,
reader => $GETTER . $UNDER . $uri,
init_arg => $uri,
);
}
has '_category' => (
is => 'ro',
isa => enum( [@CATEGORIES] ),
reader => 'get_category',
init_arg => 'category',
);
has '_keywords' => (
is => 'ro',
isa => 'ArrayRef[Str]',
reader => 'get_keywords',
init_arg => 'keywords',
);
no Moose;
## no critic qw(RequireExplicitInclusion)
__PACKAGE__->meta->make_immutable;
## use critic
1;
__END__
=encoding utf8
=for stopwords Roland van Ipenburg API NOS DateTime URL URI Readonly
=head1 NAME
WWW::NOS::Open::Document - Class representing a client side document in the
L REST API.
=head1 VERSION
This document describes WWW::NOS::Open::Document version 0.02.
=head1 SYNOPSIS
use WWW::NOS::Open::Document;
=head1 DESCRIPTION
This class represents the documents that appear in the search results.
=head1 SUBROUTINES/METHODS
=head2 C
Create a new document object.
=over
=item 1. A hash containing the properties and their values.
=back
=head2 C
Returns the id of the document as string.
=head2 C
Returns the type of the document as string C, C, C