[libweasel-perl] 09/11: * Add driver API check during session initialisation
Robert James Clay
jame at rocasa.us
Tue Aug 15 19:16:17 UTC 2017
This is an automated email from the git hooks/post-receive script.
jame-guest pushed a commit to tag v0.10
in repository libweasel-perl.
commit 593db6d096a347918d2189b667ee9762784fb7f5
Author: Erik Huelsmann <ehuels at gmail.com>
Date: Fri Sep 9 22:19:31 2016 +0200
* Add driver API check during session initialisation
---
lib/Weasel/Session.pm | 23 +++++++++++++++++++----
t/01-logging.t | 4 ++++
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/lib/Weasel/Session.pm b/lib/Weasel/Session.pm
index 8b4d60d..4027d44 100644
--- a/lib/Weasel/Session.pm
+++ b/lib/Weasel/Session.pm
@@ -115,6 +115,7 @@ Upon instantiation can be set to log consumer; a function of 3 arguments:
has 'log_hook' => (is => 'ro',
isa => 'Maybe[CodeRef]');
+
=item page_class
Upon instantiation can be set to an alternative class name for the C<page>
@@ -409,6 +410,18 @@ sub wait_for {
},
'wait_for', 'waiting for condition');
}
+
+
+before 'BUILDARGS', sub {
+ my ($class, @args) = @_;
+ my $args = (ref $args[0]) ? $args[0] : { @args };
+
+ confess "Driver used to construct session object uses old API version;
+some functionality may not work correctly"
+ if ($args->{driver}
+ && $args->{driver}->implements < $Weasel::DriverRole::VERSION);
+};
+
sub _appending_wrap {
my ($str) = @_;
return sub {
@@ -421,6 +434,7 @@ sub _appending_wrap {
}
}
}
+
=item _logged($wrapped_fn, $event, $log_item, $log_item_pre)
Invokes C<log_hook> when it's defined, before and after calling C<$wrapped_fn>
@@ -430,11 +444,12 @@ C<$log_item> can be a fixed string or a function of one argument returning
the string to be logged. The argument passed into the function is the value
returned by the C<$wrapped_fn>.
-In case there is no C<$log_item_pre> to be called on the 'pre_' event, C<$log_item>
-will be used instead, with no arguments.
+In case there is no C<$log_item_pre> to be called on the 'pre_' event,
+C<$log_item> will be used instead, with no arguments.
-For performance reasons, the C<$log_item> and C<$log_item_pre> - when coderefs - aren't
-called; instead they are passed as-is to the C<$log_hook> for lazy evaluation.
+For performance reasons, the C<$log_item> and C<$log_item_pre> - when
+coderefs - aren't called; instead they are passed as-is to the
+C<$log_hook> for lazy evaluation.
=cut
diff --git a/t/01-logging.t b/t/01-logging.t
index 0ae98a1..0a4b6cc 100644
--- a/t/01-logging.t
+++ b/t/01-logging.t
@@ -10,6 +10,10 @@ use Data::Dumper;
use Moose;
with 'Weasel::DriverRole';
+sub implements {
+ return $Weasel::DriverRole::VERSION;
+}
+
sub tag_name {
my ($self, $tag) = @_;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libweasel-perl.git
More information about the Pkg-perl-cvs-commits
mailing list