File: MooObjectWithDelegate.pm

package info (click to toggle)
libmoo-perl 1.006001-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 772 kB
  • ctags: 202
  • sloc: perl: 2,348; sh: 18; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 470 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package MooObjectWithDelegate;
use ClassicObject;
use Scalar::Util ();
use Moo;

has 'delegated' => (
  is => 'ro',
  isa => sub {
    do { $_[0] && Scalar::Util::blessed($_[0]) }
      or die "Not an Object!";
  },
  lazy => 1,
  builder => '_build_delegated',
  handles => [qw/connect/],
);

sub _build_delegated {
  my $self = shift;
  return ClassicObject->new;
}

around 'connect', sub {
  my ($orig, $self, @args) = @_;
  return $self->$orig(@args) . 'b';
};


1;