NAME

Data::Message::Board::Comment - Data object for Message board comment.

SYNOPSIS

use Data::Message::Board::Comment;

my $obj = Data::Message::Board::Comment->new(%params);
my $author = $obj->author;
my $date = $obj->date;
my $id = $obj->id;
my $message = $obj->message;

METHODS

new

my $obj = Data::Message::Board::Comment->new(%params);

Constructor.

  • author

    Author object which is Data::Person instance.

    It's required.

  • date

    Date of comment which is DateTime instance.

    It's required.

  • id

    Id.

    Default value is undef.

  • message

    Main comment message. Max length of message is 4096 character.

    It's required.

Returns instance of object.

author

my $author = $obj->author;

Get author instance.

Returns Data::Person instance.

date

my $date = $obj->date;

Get datetime of comment.

Returns DateTime instance.

id

my $id = $obj->id;

Get comment id.

Returns natural number.

my $message = $obj->message;

Get comment message.

Returns string.

ERRORS

new():
        From Mo::utils::check_isa():
                Parameter 'author' must be a 'Data::Person' object.
                        Value: %s
                        Reference: %s
                Parameter 'date' must be a 'DateTime' object.
                        Value: %s
                        Reference: %s
        From Mo::utils::check_length():
                Parameter 'message' has length greater than '4096'.
                        Value: %s
        From Mo::utils::check_number_id():
                Parameter 'id' must be a natural number.
                        Value: %s
        From Mo::utils::check_required():
                Parameter 'author' is required.
                Parameter 'date' is required.
                Parameter 'message' is required.

EXAMPLE

use strict;
use warnings;

use Data::Person;
use Data::Message::Board::Comment;
use DateTime;
use Unicode::UTF8 qw(decode_utf8 encode_utf8);

my $obj = Data::Message::Board::Comment->new(
        'author' => Data::Person->new(
                'email' => 'skim@cpan.org',
                'name' => decode_utf8('Michal Josef Špaček'),
        ),
        'date' => DateTime->now,
        'id' => 7,
        'message' => 'I am fine.',
);

# Print out.
print 'Author name: '.encode_utf8($obj->author->name)."\n";
print 'Author email: '.$obj->author->email."\n";
print 'Date: '.$obj->date."\n";
print 'Id: '.$obj->id."\n";
print 'Comment message: '.$obj->message."\n";

# Output:
# Author name: Michal Josef Špaček
# Author email: skim@cpan.org
# Date: 2024-05-27T09:54:28
# Id: 7
# Comment message: I am fine.

DEPENDENCIES

Mo, Mo::utils.

REPOSITORY

https://github.com/michal-josef-spacek/Data-Message-Board

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2024 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.01