Skip to content

Commit

Permalink
Remove some deprecated methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
beanz committed Oct 24, 2011
1 parent 4ad880d commit 02f131c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 55 deletions.
51 changes: 1 addition & 50 deletions lib/xPL/Message.pm
Expand Up @@ -106,31 +106,17 @@ sub new {
my $pkg = shift;

my %p = @_;
if ($p{validate} || $ENV{XPL_MESSAGE_VALIDATE} || !exists $p{message_type}) {
if ($p{validate} || $ENV{XPL_MESSAGE_VALIDATE}) {
require xPL::ValidatedMessage;
import xPL::ValidatedMessage;
return xPL::ValidatedMessage->new(@_);
}
my $self = { _verbose => $p{verbose}||0, };
bless $self, $pkg;

if (exists $p{class}) {
warnings::warnif('deprecated',
'"class" is deprecated. Set "schema" to "class.class_type" instead');
$p{schema} = $p{class};
delete $p{class};
if (exists $p{class_type}) {
warnings::warnif('deprecated',
'"class_type" is deprecated. '.
'Set "schema" to "class.class_type" instead');
$p{schema} .= '.'.$p{class_type};
}
}

defined $p{schema} or $pkg->argh(q{requires 'schema' parameter});
$self->{_schema} = $p{schema};

# next line isn't hit yet but will be after deprecation handling is removed
exists $p{message_type} or $pkg->argh(q{requires 'message_type' parameter});
my $message_type = $p{message_type};
exists $MESSAGE_TYPES{$message_type} or
Expand Down Expand Up @@ -162,16 +148,6 @@ sub new {

sub DESTROY { }

our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my $name = $AUTOLOAD;
$name =~ s/.*://;
$self->ouch('calling invalid or deprecated method. '.
"Use field('$name') to obtain body field values instead");
$self->field($name);
}

=head2 C<new_from_payload( $message )>
This is a constructor that takes the string of an xPL message and
Expand Down Expand Up @@ -210,31 +186,6 @@ sub new_from_payload {
return $_[0]->new(strict => 0, %r);
}

sub strict {
warnings::warnif('deprecated',
'"strict" is deprecated. Set env var "XPL_MESSAGE_VALIDATE=1" instead');
0;
}

sub extra_field {
warnings::warnif('deprecated',
'"extra_field" is deprecated. use "field" method instead');
shift->field(@_);
}

sub extra_fields {
warnings::warnif('deprecated',
'"extra_fields" is deprecated. "body_fields" returns all fields now');
return;
}

sub extra_field_string {
warnings::warnif('deprecated',
'"extra_field_string" is deprecated. "body_content" includes all fields now'
);
return '';
}

sub _parse_head {
my %r;
foreach (split /\n/, $_[0]->{_head_content}) {
Expand Down
6 changes: 3 additions & 3 deletions t/03-message-errors.t
Expand Up @@ -15,15 +15,15 @@ ok($valid_msg, 'sample message to get message type');
my $ref = ref $valid_msg;
my $msg;
is(test_error(sub { $msg = xPL::Message->new(); }),
"xPL::ValidatedMessage->new: requires 'schema' parameter",
$ref."->new: requires 'schema' parameter",
"xPL::Message missing schema test");

is(test_error(sub { $msg = xPL::Message->new(schema => "remote.basic") }),
"xPL::ValidatedMessage->new: requires 'message_type' parameter",
$ref."->new: requires 'message_type' parameter",
"xPL::Message missing message type test");

is(test_error(sub { $msg = xPL::Message->new(schema => "unknown.basic") }),
"xPL::ValidatedMessage->new: requires 'message_type' parameter",
$ref."->new: requires 'message_type' parameter",
"xPL::Message missing message type test");

is(test_error(sub { $msg = xPL::Message->new(schema => "fred.schema",
Expand Down
2 changes: 1 addition & 1 deletion t/05-listener-send-methods.t
Expand Up @@ -92,7 +92,7 @@ is(test_error(sub {
'command=write text="This is a test"')
}),
'xPL::Listener->send_aux: message error: '.
"xPL::ValidatedMessage->new: requires 'schema' parameter",
"xPL::Message->new: requires 'schema' parameter",
'missing schema.type');

is(join("!!",xPL::Listener::simple_tokenizer('test=1 2 3 ~ stop')),
Expand Down
2 changes: 1 addition & 1 deletion t/05-listener.t
Expand Up @@ -396,7 +396,7 @@ ok($xpl->remove_input($handle), "remove input");

is(test_error(sub { $xpl->send(invalid => 'messagedata'); }),
"MY::Listener->send_aux: message error: ".
"xPL::ValidatedMessage->new: requires 'schema' parameter",
"xPL::Message->new: requires 'schema' parameter",
"send with invalid message data");

check_stats(0,0,6);
Expand Down

0 comments on commit 02f131c

Please sign in to comment.