package LATMOS::Accounts::Bases::Mail::Revaliases;

use strict;
use warnings;

use base qw(LATMOS::Accounts::Bases::Mail::objects);
use LATMOS::Accounts::Log;

our $VERSION = (q$Rev: 641 $ =~ /^Rev: (\d+) /)[0];

sub new {
    my ($class, $base, $id, @args) = @_;
    if (exists($base->{revaliases}{$id})) {
        return bless({}, $class);
    } else { return }
}

sub _canonical_fields {
    my ($self, $for) = @_;
    return (qw(as));
}

sub _get_field_name {
    my ($self, $c_field, $base, $for) = @_;
    for ($c_field) {
        /^as$/ and last;
        return;
    }
    return $c_field;
}

sub get_field {
    my ($self, $field) = @_;
    $field eq 'as' and return $self->base->{revaliases}{$self->id};
    return
}

sub set_fields {
    my ($self, %data) = @_;
    if ($data{as}) {
        $self->base->{revaliases}{$self->id} = $data{as};
        return 1;
    }
    return
}

1;
