SQL::Translator::Role::ListAttr(3pm)

SQL::Translator::Role::ListAttr3pm

Context-sensitive list attributes

Usage

    package Foo;
        use Moo;
        use SQL::Translator::Role::ListAttr;
        with ListAttr foo => ( uniq => 1, append => 1 );

Overview

This package provides a variable Moo::Role for context-sensitive list attributes.

Functions

ListAttr $name => %parameters;

Returns a Moo::Role providing an arrayref attribute named $name, and wrapping the accessor to provide context-sensitivity both for setting and getting. If no "builder" or "default" is provided, the default value is the empty list.

On setting, the arguments are parsed using "parse_list_arg" in SQL::Translator::Utils, and the accessor will return an array reference or a list, depending on context.

Parameters

append

If true, the setter will append arguments to the existing ones, rather than replacing them.

uniq

If true, duplicate items will be removed, keeping the first one seen.

may_throw

If accessing the attribute might throw an exception (e.g. from a "builder" or "isa" check), this should be set to make the accessor store the exception using SQL::Translator::Role::Error and return undef.

undef_if_empty

If true, and the list is empty, the accessor will return "undef" instead of a reference to an empty in scalar context.

Unknown parameters are passed through to the has call for the attribute.

Releases

6 releases since Debian 8 (Jessie); the text changed 5 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13

From libsql-translator-perl 1.66-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.