Scroll to navigation

MouseX::NativeTraits::CodeRef(3pm) User Contributed Perl Documentation MouseX::NativeTraits::CodeRef(3pm)

NAME

MouseX::NativeTraits::CodeRef - Helper trait for CodeRef attributes

SYNOPSIS

  package Foo;
  use Mouse;
  has 'callback' => (
      traits    => ['Code'],
      is        => 'ro',
      isa       => 'CodeRef',
      default   => sub { sub { print "called" } },
      handles   => {
          call => 'execute',
      },
  );
  my $foo = Foo->new;
  $foo->call; # prints "called"

DESCRIPTION

This provides operations on coderef attributes.

PROVIDED METHODS

Calls the coderef with the given args.

METHODS

SEE ALSO

MouseX::NativeTraits

2022-06-16 perl v5.34.0