
package Text::Wigwam::Stash::Base::Metachar;

# This is the base Metachar class which contains some useful functions
# for Metachar classes.

use strict;
use warnings;
no warnings 'uninitialized';

our $VERSION = '0.01';

# When a code reference or object method is invoked by a magic metacharacter
# and it results in a list of values in excess of a single value, those values
# are condensed into a single array reference value.

sub _condense {
    my ( undef, @args ) = @_;
    return [@args] if scalar @args > 1;
    return $args[0];
}

# In the world of magic metacharacter manipulations, a reference to the value
# is often necessary, particularly in the case of scalar values.

sub _ref_rref {
    my ( undef, @args ) = @_;
    return @args if scalar @args >= 2;
    my ($ref) = @args;
    return ( $ref, \$ref ) unless ref($ref);
    return ( $ref, $ref );
}

1;
