File Coverage

blib/lib/Web/Dash/Util.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package Web::Dash::Util;
2 1     1   4 use strict;
  1         1  
  1         39  
3 1     1   7 use warnings;
  1         2  
  1         33  
4 1     1   7 use Future::Q;
  1         2  
  1         17  
5 1     1   182 use Net::DBus;
  0            
  0            
6             use Net::DBus::Annotation qw(dbus_call_async);
7             use Try::Tiny;
8             use Exporter qw(import);
9              
10             our @EXPORT_OK = qw(future_dbus_call);
11              
12             sub future_dbus_call {
13             my ($dbus_object, $method, @args) = @_;
14             return Future::Q->try(sub {
15             my $future = Future::Q->new;
16             $dbus_object->$method(dbus_call_async, @args)->set_notify(sub {
17             my $reply = shift;
18             try {
19             $future->fulfill($reply->get_result);
20             }catch {
21             my $e = shift;
22             $future->reject($e);
23             };
24             });
25             return $future;
26             });
27             }
28              
29              
30             1;