develooper Front page | perl.moose | Postings from March 2012

Problems with delegation using "handles"

Thread Next
From:
Marcos Barbeitos
Date:
March 14, 2012 10:22
Subject:
Problems with delegation using "handles"
Message ID:
CA+gEHsWrHo3TTQE24j+KG-f2ytCmXNNHTTL=ByyvXExE=uyMHw@mail.gmail.com
Howdy moosers, if I try to use the following package:

--
package Test_Handle;

use Moose;
use MooseX::StrictConstructor;

use DBIx::Custom;

has 'dbix_custom' =>
(
    is => 'ro'
  , isa => 'DBIx::Custom'
  , lazy_build => 1
  , handles => qr/.+/
);
__PACKAGE__->meta->make_immutable;
1;

--
perl -e 'use Test_Handle'
--

I get:

Can't use string ("Test_Handle") as a HASH ref while "strict refs" in
use at reader Test_Handle::dbix_custom (defined at Test_Handle.pm line
8) line 5.
BEGIN failed--compilation aborted at -e line 1.

However, if I try to delegate a single method:

--
package Test_Handle;

use Moose;
use MooseX::StrictConstructor;

use DBIx::Custom;

has 'dbix_custom' =>
(
    is => 'ro'
  , isa => 'DBIx::Custom'
  , lazy_build => 1
  , handles => qr/update/
);
__PACKAGE__->meta->make_immutable;
1;

--
perl -e 'use Test_Handle'
--

It works. Any ideas?  Thanks!

Marcos.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About