Skip to content

Commit

Permalink
Work around Role::[email protected] bug with roles that have stub subs
Browse files Browse the repository at this point in the history
... by not declaring a stub and instead putting our has above
the 'with'.
  • Loading branch information
wolfsage committed Aug 17, 2021
1 parent 93eadad commit ddfeefc
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions lib/JMAP/Tester/WebSocket/Response.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ package JMAP::Tester::WebSocket::Response;
# ABSTRACT: what you get in reply to a succesful JMAP request

use Moo;

# We can't use 'sub sentencebroker;' as a stub here as it conflicts
# with older Role::Tiny versions (2.000006, 2.000008, and others).
# With the stub, we'd see this error during compilation:
#
# Can't use string ("-1") as a symbol ref while "strict refs" in use at
# /usr/share/perl5/Role/Tiny.pm line 382
#
# We could pin a newer Role::Tiny version but this fix is easy enough

has sentence_broker => (
is => 'ro',
lazy => 1,
init_arg => undef,
default => sub {
my ($self) = @_;
JMAP::Tester::SentenceBroker->new({ response => $self });
},
);


with 'JMAP::Tester::Role::SentenceCollection', 'JMAP::Tester::WebSocket::Role::WebSocketResult';

use JMAP::Tester::Response::Sentence;
Expand Down Expand Up @@ -62,15 +83,4 @@ sub dump_diagnostic {
$self->_diagnostic_dumper->($value);
}

sub sentence_broker;
has sentence_broker => (
is => 'ro',
lazy => 1,
init_arg => undef,
default => sub {
my ($self) = @_;
JMAP::Tester::SentenceBroker->new({ response => $self });
},
);

1;

0 comments on commit ddfeefc

Please sign in to comment.