pod
[gitmo/MooseX-Emulate-Class-Accessor-Fast.git] / lib / MooseX / Emulate / Class / Accessor / Fast.pm
index 154aabf..503f54f 100644 (file)
@@ -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<Class::MOP::Attribute>. 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<Moose::Meta::Class>.
 L<Moose>, L<Moose::Meta::Attribute>, L<Class::Accessor>, L<Class::Accessor::Fast>,
 L<Class::MOP::Attribute>, L<MooseX::Adopt::Class::Accessor::Fast>
 
-=head1 AUTHOR
+=head1 AUTHORS
+
+Guillermo Roditi (groditi) E<lt>groditi@cpan.orgE<gt>
+
+With contributions from:
+
+=over 4
+
+=item Tomas Doran E<lt>bobtfish@bobtfish.netE<gt>
 
-Guillermo Roditi (groditi) <groditi@cpan.org>
+=back
 
 =head1 LICENSE