From 231745b0fd56e122e09165e1d8ffd57ae86ae749 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 21 Feb 2011 11:19:00 -0600 Subject: handle defaults with native traits properly --- lib/MooseX/Bread/Board/Meta/Role/Attribute.pm | 6 ++++++ t/10-inlining.t | 16 +++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/MooseX/Bread/Board/Meta/Role/Attribute.pm b/lib/MooseX/Bread/Board/Meta/Role/Attribute.pm index e44b30e..19492ae 100644 --- a/lib/MooseX/Bread/Board/Meta/Role/Attribute.pm +++ b/lib/MooseX/Bread/Board/Meta/Role/Attribute.pm @@ -2,6 +2,7 @@ package MooseX::Bread::Board::Meta::Role::Attribute; use Moose::Role; use Bread::Board::Types; +use List::MoreUtils qw(any); use MooseX::Bread::Board::BlockInjection; use MooseX::Bread::Board::ConstructorInjection; @@ -101,6 +102,11 @@ after _process_options => sub { || exists $opts->{block} || exists $opts->{value}; + # XXX: uggggh + return if any { $_ eq 'Moose::Meta::Attribute::Native::Trait::String' + || $_ eq 'Moose::Meta::Attribute::Native::Trait::Counter' } + @{ $opts->{traits} }; + die "default is not valid when Bread::Board service options are set"; }; diff --git a/t/10-inlining.t b/t/10-inlining.t index 091e7c6..080cefc 100644 --- a/t/10-inlining.t +++ b/t/10-inlining.t @@ -20,7 +20,7 @@ use Test::More; has bool => ( traits => ['Bool'], isa => 'Bool', - default => 0, + value => 0, handles => { bool_unset => 'unset', bool_set => 'set', @@ -32,7 +32,8 @@ use Test::More; has string => ( traits => ['String'], isa => 'Str', - default => '', + value => '', + default => '', # XXX: ugh, needed because of the default_default stuff handles => { string_prepend => 'prepend', string_chop => 'chop', @@ -50,7 +51,7 @@ use Test::More; has hash => ( traits => ['Hash'], isa => 'HashRef', - default => sub { {} }, + block => sub { {} }, handles => { hash_delete => 'delete', hash_exists => 'exists', @@ -71,7 +72,8 @@ use Test::More; has counter => ( traits => ['Counter'], isa => 'Int', - default => 1, + value => 0, + default => 0, # XXX: ugh, needed because of the default_default stuff handles => { counter_set => 'set', counter_reset => 'reset', @@ -83,7 +85,7 @@ use Test::More; has code => ( traits => ['Code'], isa => 'CodeRef', - default => 1, + block => sub { sub { } }, handles => { code_execute => 'execute', code_execute_method => 'execute_method', @@ -93,7 +95,7 @@ use Test::More; has array => ( traits => ['Array'], isa => 'ArrayRef', - default => sub { [] }, + block => sub { [] }, handles => { array_unshift => 'unshift', array_shuffle => 'shuffle', @@ -125,7 +127,7 @@ use Test::More; has number => ( traits => ['Number'], isa => 'Num', - default => 1, + value => 1, handles => { number_add => 'add', number_set => 'set', -- cgit v1.2.3-54-g00ecf