From: Matt S Trout Date: Mon, 3 Feb 2014 13:12:32 +0000 (+0000) Subject: allow value scalarref, refactor X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FDKit.git;a=commitdiff_plain;h=e183503f954cd8cf5640f933f308c310db88456c allow value scalarref, refactor --- diff --git a/lib/DX/Role/Op.pm b/lib/DX/Role/Op.pm index 813cea7..83b9e86 100644 --- a/lib/DX/Role/Op.pm +++ b/lib/DX/Role/Op.pm @@ -28,6 +28,8 @@ sub _expand_argspec { } else { die "Arrayref in argspec is not value"; } + } elsif (ref($spec) eq 'SCALAR' or ref($spec) eq 'REF') { + return +{ bound_value => $$spec }; } else { die "Argspec incomprehensible"; } diff --git a/t/dot_ssh.t b/t/dot_ssh.t index 6c3bc9d..6e0a1c6 100644 --- a/t/dot_ssh.t +++ b/t/dot_ssh.t @@ -53,29 +53,23 @@ my $solver = DX::Solver->new( $solver->add_rule(@$_) for ( [ path_status => [ qw(PS) ], - [ member_of => 'PS', [ value => 'path_status' ] ] ], + [ member_of => 'PS', \'path_status' ] ], [ path => [ qw(PS P) ], - [ prop => 'PS', [ value => 'path' ], 'P' ] ], - [ mode => [ qw(PS M) ], + [ prop => 'PS', \'path', 'P' ] ], + [ info_prop => [ qw(PS N V) ], [ exists => [ qw(PSI) ], - [ prop => 'PS', [ value => 'info' ], 'PSI' ], - [ prop => 'PSI', [ value => 'mode' ], 'M' ] ] ], + [ prop => 'PS', \'info', 'PSI' ], + [ prop => 'PSI', 'N', 'V' ] ] ], + [ mode => [ qw(PS M) ], + [ info_prop => 'PS', \'mode', 'M' ] ], [ exists_path => [ qw(PS) ], - [ exists => [ qw(PSI) ], - [ prop => 'PS', [ value => 'info' ], 'PSI' ], - [ prop => 'PSI', [ value => 'is_directory' ], [ value => 1 ] ] ] ], + [ info_prop => 'PS', \'is_directory', \1 ] ], [ exists_path => [ qw(PS) ], - [ exists => [ qw(PSI) ], - [ prop => 'PS', [ value => 'info' ], 'PSI' ], - [ prop => 'PSI', [ value => 'is_file' ], [ value => 1 ] ] ] ], + [ info_prop => 'PS', \'is_file', \1 ] ], [ is_directory => [ qw(PS) ], - [ exists => [ qw(PSI) ], - [ prop => 'PS', [ value => 'info' ], 'PSI' ], - [ prop => 'PSI', [ value => 'is_directory' ], [ value => 1 ] ] ] ], + [ info_prop => 'PS', \'is_directory', \1 ] ], [ is_file => [ qw(PS) ], - [ exists => [ qw(PSI) ], - [ prop => 'PS', [ value => 'info' ], 'PSI' ], - [ prop => 'PSI', [ value => 'is_file' ], [ value => 1 ] ] ] ], + [ info_prop => 'PS', \'is_file', \1 ] ], ); %path_status = %protos;