| 1 | package App::Acmeman::Source; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use Carp; | ||
| 6 | |||
| 7 | sub set { | ||
| 8 | my $self = shift; | ||
| 9 | croak "improper use of the set method" | ||
| 10 | unless exists $self->{_cfg}; | ||
| 11 | return $self->{_cfg}->set(@_); | ||
| 12 | } | ||
| 13 | |||
| 14 | sub add { | ||
| 15 | my $self = shift; | ||
| 16 | croak "improper use of the add method" | ||
| 17 | unless exists $self->{_cfg}; | ||
| 18 | return $self->{_cfg}->add_value(@_); | ||
| 19 | } | ||
| 20 | |||
| 21 | sub get { | ||
| 22 | my $self = shift; | ||
| 23 | croak "improper use of the get method" | ||
| 24 | unless exists $self->{_cfg}; | ||
| 25 | return $self->{_cfg}->get(@_); | ||
| 26 | } | ||
| 27 | |||
| 28 | sub is_set { | ||
| 29 | my $self = shift; | ||
| 30 | croak "improper use of the get method" | ||
| 31 | unless exists $self->{_cfg}; | ||
| 32 | return $self->{_cfg}->is_set(@_); | ||
| 33 | } | ||
| 34 | |||
| 35 | sub define_domain { | ||
| 36 | my $self = shift; | ||
| 37 | my $cn = shift || croak "domain name must be given"; | ||
| 38 | $self->set('domain', $cn, 'files', 'default') | ||
| 39 | unless $self->is_set('domain', $cn, 'files'); | ||
| 40 | } | ||
| 41 | |||
| 42 | sub define_alias { | ||
| 43 | my $self = shift; | ||
| 44 | my $cn = shift || croak "domain name must be given"; | ||
| 45 | foreach my $alias (@_) { | ||
| 46 | $self->add(['domain', $cn, 'alt'], $alias); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | sub configure { | ||
| 51 | my ($self, $config) = @_; | ||
| 52 | $self->{_cfg} = $config; | ||
| 53 | return $self->scan(); | ||
| 54 | } | ||
| 55 | |||
| 56 | sub setup { 1 } | ||
| 57 | |||
| 58 | 1; |