package Peace::Model::Build; use v5.30.0; use strict; use warnings; use Params::ValidationCompiler qw/validation_for/; use Types::Standard qw/Str InstanceOf Bool HasMethods/; use DateTime; use Peace::DAO::Release; { my $validator = validation_for( params => { uuid => { type => Str, optional => 1 }, date_creation => { type => InstanceOf ['DateTime'], optional => 1 }, release => { type => InstanceOf ['Peace::Model::Release'], optional => 1 }, release_uuid => { type => Str, optional => 1, }, dbh => { type => HasMethods ['selectall_arrayref'], optional => 1 }, success => { type => Bool }, log => { type => Str }, arch => { type => Str, }, } ); sub new { my $class = shift; my %params = $validator->(@_); die 'release or release_uuid should be passed on construct' unless exists $params{release} || ( exists $params{release_uuid} && exists $params{dbh} ); my $self = bless {%params}, $class; return $self; } } { my $validator = validation_for( params => [ { type => Str, optional => 1 }, ] ); sub uuid { my $self = shift; if (@_) { my ($new_uuid) = $validator->(@_); $self->{uuid} = $new_uuid; } return $self->{uuid}; } } { my $validator = validation_for( params => [ { type => InstanceOf ['DateTime'], optional => 1 } ] ); sub date_creation { my $self = shift; if (@_) { my ($new_date_creation) = $validator->(@_); $self->{date_creation} = $new_date_creation; } return $self->{date_creation}; } } { my $validator = validation_for( params => [ { type => InstanceOf ['Peace::Model::Release'], optional => 1 } ] ); sub release { my $self = shift; if (@_) { my ($new_release) = $validator->(@_); $self->{release} = $new_release; } if ( !defined $self->{release} ) { my $release_dao = Peace::DAO::Release->new( dbh => $self->_dbh ); $self->{release} = $release_dao->recover_by_uuid( uuid => $self->{release_uuid} ); } return $self->{release}; } } { my $validator = validation_for( params => [ { type => Str, optional => 1, } ] ); sub arch { my $self = shift; if (@_) { my ($new_arch) = $validator->(@_); $self->{arch} = $new_arch; } return $self->{arch}; } } { my $validator = validation_for( params => [ { type => Str, optional => 1, } ] ); sub log { my $self = shift; if (@_) { my ($new_log) = $validator->(@_); $self->{log} = $new_log; } return $self->{log}; } } { my $validator = validation_for( params => [ { type => Bool, optional => 1, } ] ); sub success { my $self = shift; if (@_) { my ($new_success) = $validator->(@_); $self->{success} = $new_success; } return $self->{success}; } } sub _dbh { my $self = shift; return $self->{dbh}; } 1; =encoding utf8 =head1 NAME Peace::Model::Build - An object representing a release build for an architecture. =head1 SYNOPSIS my $build = Peace::Model::Build->new( release => $release, arch => $arch, ); =head1 DESCRIPTION Peace::Model::Build represents a successful build for an architecture of L. =head1 INSTANCE METHODS Peace::Model::Build implements the following instance methods: =head2 new my $build = Peace::Model::Build->new( uuid => $uuid, # optional date_creation => $date_creation, # optional release => $release, # required or release_uuid should be passed. release_uuid => $release_uuid, # required or release should be passed, dbh => $dbh, # needed if release_uuid is passed. arch => $arch, ); Instances a Peace::Model::Build. =head1 METHODS Peace::Model::Build implements the following methods: =head2 uuid my $uuid = $build->uuid; $build->uuid($uuid); Allows to set and retrieve the uuid attribute. =head2 date_creation my $date_creation = $build->date_creation; $build->date_creation($date_creation); Allows to set and retrieve the date_creation attribute as a L. =head2 release my $release = $build->release; $build->release($release); Allows to set and retrieve the release attribute as a L. =head2 arch my $arch = $build->arch; $build->arch($arch); Allows to set and retrieve the architecture attribute. =head2 log my $log = $build->log; $build->log($log); Allows to set an retrieve the build log. =head2 success my $success = $build->success; $build->success($success); Allows to set and retrieve the build success status. =head1 SEE ALSO L, L =cut