Business-OnlinePayment-CyberSource
view release on metacpan or search on metacpan
lib/Business/OnlinePayment/CyberSource/Role/InputHandling.pm view on Meta::CPAN
package Business::OnlinePayment::CyberSource::Role::InputHandling;
use 5.010;
use strict;
use warnings;
use namespace::autoclean;
use Moose::Role;
# ABSTRACT: Input handling convenience methods for Business::OnlinePayment::CyberSource
our $VERSION = '3.000016'; # VERSION
#### Subroutine Definitions ####
# Converts input into a hashref
# Accepts: A hash or reference to a hash
# Returns: A reference to the supplied hash
sub _parse_input { ## no critic ( Subroutines::ProhibitUnusedPrivateSubroutines )
my ( undef, @args ) = @_;
my $data = {};
# shift off first element if only one exists and is of type HASH
if ( scalar @args == 1 && ref $args[0] eq 'HASH' ) {
$data = shift @args;
}
# Cast into a hash if number of elements is even and first element is a string
elsif ( ( scalar @args % 2 ) == 0 && ref $args[0] eq '' ) {
$data = { @args };
}
return $data;
}
1;
__END__
=pod
=head1 NAME
Business::OnlinePayment::CyberSource::Role::InputHandling - Input handling convenience methods for Business::OnlinePayment::CyberSource
=head1 VERSION
version 3.000016
=head1 SYNOPSIS
package Thing;
use Moose;
with 'Business::OnlinePayment::CyberSource::Role::InputHandling';
sub blah {
my ( $self, @args ) = @_;
my $data = $self->_parse_input( @args );
$data->{color} = 'red' unless $data->{color};
}
1;
my $thing = Thing->new();
( run in 0.791 second using v1.01-cache-2.11-cpan-524268b4103 )