Fedora::Bugzilla::Bug::NewAttachment - Define the paramaters needed to create an attachment


Fedora-Bugzilla documentation Contained in the Fedora-Bugzilla distribution.

Index


Code Index:

NAME

Top

Fedora::Bugzilla::Bug::NewAttachment - Define the paramaters needed to create an attachment

SYNOPSIS

Top

	use <Module::Name>;
	# Brief but working code example(s) here showing the most common usage(s)

	# This section will be as far as many users bother reading
	# so make it as educational and exemplary as possible.




DESCRIPTION

Top

A full description of the module and its features. May include numerous subsections (i.e. =head2, =head3, etc.)

SUBROUTINES/METHODS

Top

A separate section listing the public components of the module's interface. These normally consist of either subroutines that may be exported, or methods that may be called on objects belonging to the classes that the module provides. Name the section accordingly.

In an object-oriented module, this section should begin with a sentence of the form "An object of this class represents...", to give the reader a high-level context to help them understand the methods that are subsequently described.

SEE ALSO

Top

Fedora::Bugzilla::Bug, Fedora::Bugzilla::Attachment.

BUGS AND LIMITATIONS

Top

All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or (preferably) add the bug to the camelus ticket tracker at https://fedorahosted.org/camelus/newticket.

Patches are welcome.

AUTHOR

Top

Chris Weyl <cweyl@alumni.drew.edu>

LICENSE AND COPYRIGHT

Top


Fedora-Bugzilla documentation Contained in the Fedora-Bugzilla distribution.

#############################################################################
#
# Define the parameters of a new attachment.
#
# Author:  Chris Weyl (cpan:RSRCHBOY), <cweyl@alumni.drew.edu>
# Company: No company, personal work
# Created: 01/24/2009 11:13:14 AM PST
#
# Copyright (c) 2009 Chris Weyl <cweyl@alumni.drew.edu>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
#############################################################################

package Fedora::Bugzilla::Bug::NewAttachment;

use Moose;

use MooseX::StrictConstructor;
use MooseX::Types::Path::Class ':all';

with 'Fedora::Bugzilla::Role::NewHash';

use MIME::Base64;
use Path::Class;

use namespace::clean -except => 'meta';

our $VERSION = '0.13';

my @d = (is => 'rw', required => 1);

# mandatory
has filename    => (@d, isa => File, coerce => 1, predicate => 'has_filename');
has description => (@d, isa => 'Str', predicate => 'has_description'         );

# optional
has filetype    => (is => 'rw', lazy_build => 1, isa => 'Str' );
has contenttype => (
    is => 'rw', 
    isa => 'Str', 
    predicate => 'has_contenttype', 
    builder => '_build_contenttype',
);
has ispatch     => (is => 'rw', lazy_build => 1, isa => 'Bool');
has isprivate   => (is => 'rw', lazy_build => 1, isa => 'Bool');
has comment     => (is => 'rw', lazy_build => 1, isa => 'Str' );

sub _build_filetype    { undef }
sub _build_contenttype { 'text/plain' }
sub _build_ispatch     { undef }
sub _build_isprivate   { undef }
sub _build_comment     { undef }

has data => (is => 'ro', lazy_build => 1);

sub _build_data {
    my $self = shift @_;

    return encode_base64(file($self->filename)->slurp);
}

__PACKAGE__->meta->make_immutable;

1;

__END__