diff options
author | Matteo Pasotti <matteo.pasotti@gmail.com> | 2014-01-25 00:29:08 +0100 |
---|---|---|
committer | Matteo Pasotti <matteo.pasotti@gmail.com> | 2014-01-25 00:29:08 +0100 |
commit | 98da7d8102939b47709cf85c484786e37068538c (patch) | |
tree | 085f5d8be23fcee2e7c7eeb75b47c321c523b3f2 /AdminPanel | |
parent | db7cd49a868a49e46e35190f4ed73a197c8b892a (diff) | |
download | colin-keep-98da7d8102939b47709cf85c484786e37068538c.tar colin-keep-98da7d8102939b47709cf85c484786e37068538c.tar.gz colin-keep-98da7d8102939b47709cf85c484786e37068538c.tar.bz2 colin-keep-98da7d8102939b47709cf85c484786e37068538c.tar.xz colin-keep-98da7d8102939b47709cf85c484786e37068538c.zip |
- initializing configHosts attribute using moose builder
- implemented _dropHost method
Diffstat (limited to 'AdminPanel')
-rw-r--r-- | AdminPanel/Hosts/hosts.pm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/AdminPanel/Hosts/hosts.pm b/AdminPanel/Hosts/hosts.pm index 97f9a90..6b2264f 100644 --- a/AdminPanel/Hosts/hosts.pm +++ b/AdminPanel/Hosts/hosts.pm @@ -13,9 +13,15 @@ my $is_none = 0; has 'configHosts' => ( is => 'rw', - init_arg => undef + init_arg => undef, + builder => '_initialize' ); +sub _initialize { + my $self = shift(); + $self->configHosts(Config::Hosts->new()); +} + =pod =head2 _getHosts @@ -34,7 +40,7 @@ retrieve data from the hosts file (/etc/hosts) using the Config::Hosts module sub _getHosts { my $self = shift(); - $self->configHosts(Config::Hosts->new()); + # $self->configHosts(Config::Hosts->new()); my $hosts = $self->configHosts->read_hosts(); my @result = (); while( my ($key, $value) = each($hosts)){ @@ -57,6 +63,12 @@ sub _insertHost { return $self->configHosts->insert_host(ip => $ip, hosts => @host_definitions); } +sub _dropHost { + my $self = shift(); + my $host_ip = shift(); + return $self->configHosts->delete_host($host_ip); +} + sub _writeHosts { my $self = shift(); return $self->configHosts->write_hosts(); |