NAME

MoopsX::ListObjects - Use Moops with List::Objects::WithUtils

SYNOPSIS

package My::App;
use MoopsX::ListObjects;

class Foo {
  has mylist => ( 
    default => sub { array }, 
    isa     => ArrayObj
  );

  has mydata => ( 
    default => sub { +{} },
    isa     => HashObj,
    coerce  => 1
  );

  method add_items (@items) {
    $self->mylist->push(@items)
  }

  method find_matches (Str $string) {
    $self->mylist->grep(sub { $_ eq $string })
  }
}

my $foo = Foo->new;

$foo->add_items(qw/ foo bar baz /);

my $matches = $foo->find_matches( 'foo' );

DESCRIPTION

Extends Toby Inkster's Moops sugary class building syntax with List::Objects::WithUtils objects.

Importing MoopsX::ListObjects is the same as importing Moops, but you also get array, immarray, and hash objects from List::Objects::WithUtils.

You also get an extra set of types with coercions:

ArrayObj, ImmutableArray, and ImmutableArrayObj will coerce from plain ARRAY-type references to the appropriate List::Objects::WithUtils object; HashObj will do the same for HASH-type references.

SEE ALSO

Moops

List::Objects::WithUtils::Role::Array

List::Objects::WithUtils::Role::Hash

List::Objects::WithUtils::Array::Immutable

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>