| 1 | package WiX3::Traceable; | ||
| 2 | |||
| 3 | use 5.008003; | ||
| 4 | |||
| 5 | #use metaclass ( | ||
| 6 | # base_class => 'MooseX::Singleton::Object', | ||
| 7 | # metaclass => 'MooseX::Singleton::Meta::Class', | ||
| 8 | # error_class => 'WiX3::Util::Error', | ||
| 9 | #); | ||
| 10 | use MooseX::Singleton; | ||
| 11 | use WiX3::Util::StrictConstructor; | ||
| 12 | use WiX3::Trace::Object 0.011; | ||
| 13 | use WiX3::Types qw( TraceObject ); | ||
| 14 | |||
| 15 | our $VERSION = '0.011'; | ||
| 16 | |||
| 17 | with 'WiX3::Role::Traceable'; | ||
| 18 | |||
| 19 | has _traceobject => ( | ||
| 20 | is => 'bare', | ||
| 21 | isa => TraceObject, | ||
| 22 | init_arg => 'options', | ||
| 23 | weak_ref => 1, | ||
| 24 | default => sub { WiX3::Trace::Object->new() }, | ||
| 25 | ); | ||
| 26 | |||
| 27 | sub BUILDARGS { | ||
| 28 | my $class = shift; | ||
| 29 | my %args; | ||
| 30 | |||
| 31 | if ( @_ == 1 && 'HASH' eq ref $_[0] ) { | ||
| 32 | %args = %{ $_[0] }; | ||
| 33 | } else { | ||
| 34 | %args = (@_); | ||
| 35 | } | ||
| 36 | |||
| 37 | ##no critic ( RequireCarping RequireUseOfExceptions ProtectPrivateSubs ) | ||
| 38 | my $obj; | ||
| 39 | eval { | ||
| 40 | $obj = WiX3::Trace::Object->new(%args); | ||
| 41 | 1; | ||
| 42 | } || eval { | ||
| 43 | WiX3::Trace::Object->_clear_instance(); | ||
| 44 | $obj = WiX3::Trace::Object->new(%args); | ||
| 45 | 1; | ||
| 46 | } || die 'Could not create trace object'; | ||
| 47 | |||
| 48 | return { options => $obj }; | ||
| 49 | } ## end sub BUILDARGS | ||
| 50 | |||
| 51 | sub BUILD { | ||
| 52 | my $self = shift; | ||
| 53 | |||
| 54 | # Necessary for the option to carry through. | ||
| 55 | $self->get_testing(); | ||
| 56 | |||
| 57 | return; | ||
| 58 | } | ||
| 59 | |||
| 60 | 1; | ||
| 61 | |||
| 62 | __END__ |