File: builder.t

package info (click to toggle)
libmoox-types-mooselike-perl 0.27-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 192 kB
  • ctags: 14
  • sloc: perl: 492; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 456 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{

  package MyObject;
  use Moo;
  use MooX::Types::MooseLike::Base qw<ArrayRef CodeRef>;
  has attribute_with_a_builder => (
    is      => 'ro',
    isa     => ArrayRef [CodeRef],
    builder => '_build_attribute_properties',
    );

  sub _build_attribute_properties {
    [ sub { 'pie' } ];
  }
}

use Test::More;
my $object = MyObject->new;
is($object->attribute_with_a_builder->[0]->(),
  'pie', 'Parameterized type with a builder');

done_testing;