X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FEmulate%2FClass%2FAccessor%2FFast.pm;h=503f54f368e5974cc0993060461b2bcacdb86fa6;hb=d82bc8be260465d7e6e4c050dd427ca58cd4f32a;hp=154aabf42a0d704bfe27fd3c6492e0610049452b;hpb=4905e2e3f957e66cfe7d0103f4c37f4b380103a6;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 154aabf..503f54f 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.00100'; +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,6 +60,26 @@ methods in L. Example =head1 METHODS +=head2 BUILD $self %args + +Change the default Moose class building to emulate the behavior of C::A::F and +store arguments in the instance hashref. + +=cut + +sub BUILD { + my $self = shift; + my %args; + if (scalar @_ == 1 && defined $_[0] && ref($_[0]) eq 'HASH') { + %args = %{$_[0]}; + } elsif( scalar(@_) ) { + %args = @_; + } + my @extra = grep { !exists($self->{$_}) } keys %args; + @{$self}{@extra} = @args{@extra}; + return $self; +} + =head2 mk_accessors @field_names Create read-write accessors. An attribute named C<$field_name> will be created. @@ -208,9 +228,17 @@ See L. L, L, L, L, L, L -=head1 AUTHOR +=head1 AUTHORS + +Guillermo Roditi (groditi) Egroditi@cpan.orgE + +With contributions from: + +=over 4 + +=item Tomas Doran Ebobtfish@bobtfish.netE -Guillermo Roditi (groditi) +=back =head1 LICENSE