---
name: "MooX::SingleArg"
section: "3pm"
platform: "linux"
package: "libmoox-buildargs-perl"
version: "0.08-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/MooX::SingleArg"
---

# MooX::SingleArg(3pm)

Support single-argument instantiation.

## NAME

MooX::SingleArg - Support single-argument instantiation.

## SYNOPSIS

```
    package Foo;
    use Moo;
    with 'MooX::SingleArg';
    Foo->single_arg('bar');
    has bar => ( is=>'ro' );

    my $foo = Foo->new( 'goo' );
    print $foo->bar(); # goo
```

## CLASS ARGUMENTS

### single\_arg

```
    __PACKAGE__->single_arg( 'foo' );
```

Use this to declare the `"init_arg"` of the single argument.

### force\_single\_arg

```
    __PACKAGE__->force_single_arg( 1 );
```

Causes single-argument processing to happen even if a hashref is passed in as the single argument.

## CLASS METHODS

### has\_single\_arg

Returns true if "single\_arg" has been called.

## SEE ALSO

- •

  MooX::BuildArgs

- •

  MooX::BuildArgsHooks

- •

  MooX::MethodProxyArgs

- •

  MooX::Rebuild

## SUPPORT

See "SUPPORT" in MooX::BuildArgs.

## AUTHORS

See "AUTHORS" in MooX::BuildArgs.

## LICENSE

See "LICENSE" in MooX::BuildArgs.
