13 has 'bar' => (is => 'ro');
18 has 'baz' => (is => 'ro', default => 'BAZ');
23 my $foo = Foo->new(bar => 'BAR');
26 is($foo->bar, 'BAR', '... got the expect value');
27 ok(!$foo->can('baz'), '... no baz method though');
30 Bar->meta->apply($foo)
31 }, undef, '... this works' );
33 is($foo->bar, 'BAR', '... got the expect value');
34 ok($foo->can('baz'), '... we have baz method now');
35 is($foo->baz, 'BAZ', '... got the expect value');
38 # with extra params ...
40 my $foo = Foo->new(bar => 'BAR');
43 is($foo->bar, 'BAR', '... got the expect value');
44 ok(!$foo->can('baz'), '... no baz method though');
47 Bar->meta->apply($foo, (rebless_params => { baz => 'FOO-BAZ' }))
48 }, undef, '... this works' );
50 is($foo->bar, 'BAR', '... got the expect value');
51 ok($foo->can('baz'), '... we have baz method now');
52 is($foo->baz, 'FOO-BAZ', '... got the expect value');
55 # with extra params ...
57 my $foo = Foo->new(bar => 'BAR');
60 is($foo->bar, 'BAR', '... got the expect value');
61 ok(!$foo->can('baz'), '... no baz method though');
64 Bar->meta->apply($foo, (rebless_params => { bar => 'FOO-BAR', baz => 'FOO-BAZ' }))
65 }, undef, '... this works' );
67 is($foo->bar, 'FOO-BAR', '... got the expect value');
68 ok($foo->can('baz'), '... we have baz method now');
69 is($foo->baz, 'FOO-BAZ', '... got the expect value');