From 184a83c2f7885c9a08e4123fd07a73bf5ae8cb59 Mon Sep 17 00:00:00 2001 From: Jason May Date: Tue, 15 Jun 2010 12:39:26 -0400 Subject: refactor the estrablishment message into its own attribute --- lib/App/Termcast.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/App/Termcast.pm b/lib/App/Termcast.pm index 422c3be..4b51398 100644 --- a/lib/App/Termcast.pm +++ b/lib/App/Termcast.pm @@ -121,6 +121,18 @@ has _got_winch => ( init_arg => undef, ); +has establishment_message => ( + traits => ['NoGetopt'], + is => 'ro', + isa => 'Str', + lazy_build => 1, +); + +sub _build_establishment_message { + my $self = shift; + return sprintf("hello %s %s\n", $self->user, $self->password); +} + has socket => ( traits => ['NoGetopt'], is => 'rw', @@ -135,7 +147,7 @@ sub _build_socket { PeerPort => $self->port); die "Couldn't connect to " . $self->host . ": $!" unless $socket; - $socket->syswrite('hello '.$self->user.' '.$self->password."\n"); + $socket->syswrite($self->establishment_message); return $socket; } -- cgit v1.2.3-54-g00ecf