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         1  
  1         34  
4 1     1   7 use Future::Q;
  1         2  
  1         16  
5 1     1   215 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 $VERSION = "0.041";
11              
12             our @EXPORT_OK = qw(future_dbus_call);
13              
14             sub future_dbus_call {
15             my ($dbus_object, $method, @args) = @_;
16             return Future::Q->try(sub {
17             my $future = Future::Q->new;
18             $dbus_object->$method(dbus_call_async, @args)->set_notify(sub {
19             my $reply = shift;
20             try {
21             $future->fulfill($reply->get_result);
22             }catch {
23             my $e = shift;
24             $future->reject($e);
25             };
26             });
27             return $future;
28             });
29             }
30              
31              
32             1;