X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FEmulate%2FClass%2FAccessor%2FFast.pm;h=64955d687ea6807d8b68255917d2324a9ec8ebc8;hb=144866f7751f8516d55c33c6de407b9086d8c3df;hp=c75cf309348839cb9b44ac3f7cda29d32352ae5b;hpb=d21c4ca23c93d4a824f5d4cff1315640a023acd1;p=gitmo%2FMooseX-Emulate-Class-Accessor-Fast.git diff --git a/lib/MooseX/Emulate/Class/Accessor/Fast.pm b/lib/MooseX/Emulate/Class/Accessor/Fast.pm index c75cf30..64955d6 100644 --- a/lib/MooseX/Emulate/Class/Accessor/Fast.pm +++ b/lib/MooseX/Emulate/Class/Accessor/Fast.pm @@ -2,7 +2,7 @@ package MooseX::Emulate::Class::Accessor::Fast; use Moose::Role; -our $VERSION = '0.00200'; +our $VERSION = '0.00300'; =head1 NAME @@ -12,7 +12,7 @@ MooseX::Emulate::Class::Accessor::Fast - =head1 SYNOPSYS package MyClass; - Use Moose; + use Moose; with 'MooseX::Emulate::Class::Accessor::Fast'; @@ -60,27 +60,25 @@ methods in L. Example =head1 METHODS -=head2 new %args +=head2 BUILD $self %args -Extend the default Moose constructor to emulate the behavior of C::A::F and +Change the default Moose class building to emulate the behavior of C::A::F and store arguments in the instance hashref. =cut -around new => sub{ - my $orig = shift; - my $class = shift; +sub BUILD { + my $self = shift; my %args; if (scalar @_ == 1 && defined $_[0] && ref($_[0]) eq 'HASH') { %args = %{$_[0]}; } else { %args = @_; } - my $self = $class->$orig(@_); my @extra = grep { !exists($self->{$_}) } keys %args; @{$self}{@extra} = @args{@extra}; return $self; -}; +} =head2 mk_accessors @field_names