From 9a259f4341c60b2fb9ddc3aefc640081ead9f078 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 20 Feb 2011 02:29:50 -0600 Subject: pass $self to block injections --- t/04-block.t | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 t/04-block.t (limited to 't') diff --git a/t/04-block.t b/t/04-block.t new file mode 100644 index 0000000..a06a950 --- /dev/null +++ b/t/04-block.t @@ -0,0 +1,39 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +{ + package Foo; + use Moose; + use MooseX::Bread::Board; + + has foo => ( + is => 'ro', + isa => 'Str', + default => 'FOO', + ); + + has bar => ( + is => 'ro', + isa => 'Str', + value => 'BAR', + ); + + has baz => ( + is => 'ro', + isa => 'Baz', + block => sub { + my ($s, $self) = @_; + return $s->param('bar') . $self->foo; + }, + dependencies => ['bar'], + ); +} + +{ + my $foo = Foo->new; + is($foo->baz, 'BARFOO', "self is passed properly"); +} + +done_testing; -- cgit v1.2.3