Class-Accessor-Chained-0.01/0042755000175000017500000000000007760415174015731 5ustar richardcrichardcClass-Accessor-Chained-0.01/t/0042755000175000017500000000000007760415174016174 5ustar richardcrichardcClass-Accessor-Chained-0.01/t/00compile.t0100444000175000017500000000020707760414532020136 0ustar richardcrichardc#!perl -w use strict; use Test::More tests => 2; require_ok('Class::Accessor::Chained'); require_ok('Class::Accessor::Chained::Fast'); Class-Accessor-Chained-0.01/t/chained.t0100444000175000017500000000117407760414505017745 0ustar richardcrichardc#!perl -w use strict; use Test::More tests => 6; package Foo; use base 'Class::Accessor::Chained'; __PACKAGE__->mk_accessors(qw( foo bar baz )); package main; my $foo = Foo->new->foo(1)->baz(2)->bar(4); isa_ok( $foo, 'Foo' ); is( $foo->bar, 4, "get gets the value" ); is( $foo->foo( 5 ), $foo, "set gets the object" ); # and again, but with Fast accessors package Bar; use base 'Class::Accessor::Chained::Fast'; __PACKAGE__->mk_accessors(qw( foo bar baz )); package main; my $bar = Bar->new->foo(1)->baz(2)->bar(4); isa_ok( $bar, 'Bar' ); is( $bar->bar, 4, "get gets the value" ); is( $bar->foo( 5 ), $bar, "set gets the object" ); Class-Accessor-Chained-0.01/lib/0042755000175000017500000000000007760415174016477 5ustar richardcrichardcClass-Accessor-Chained-0.01/lib/Class/0042755000175000017500000000000007760415174017544 5ustar richardcrichardcClass-Accessor-Chained-0.01/lib/Class/Accessor/0042755000175000017500000000000007760415174021306 5ustar richardcrichardcClass-Accessor-Chained-0.01/lib/Class/Accessor/Chained/0042755000175000017500000000000007760415174022641 5ustar richardcrichardcClass-Accessor-Chained-0.01/lib/Class/Accessor/Chained/Fast.pm0100444000175000017500000000270207760414352024063 0ustar richardcrichardcuse strict; package Class::Accessor::Chained::Fast; use base 'Class::Accessor::Fast'; sub make_accessor { my($class, $field) = @_; return sub { my $self = shift; if(@_) { $self->{$field} = (@_ == 1 ? $_[0] : [@_]); return $self; } return $self->{$field}; }; } sub make_wo_accessor { my($class, $field) = @_; return sub { my($self) = shift; unless (@_) { my $caller = caller; require Carp; Carp::croak("'$caller' cannot access the value of '$field' on ". "objects of class '$class'"); } else { $self->{$field} = (@_ == 1 ? $_[0] : [@_]); return $self; } }; } 1; =head1 NAME Class::Accessor::Chained::Fast - Faster, but less expandable, chained accessors =head1 SYNOPSIS package Foo; use base qw(Class::Accessor::Chained::Fast); # The rest as Class::Accessor::Chained except no set() or get(). =head1 DESCRIPTION By analogue to Class::Accessor and Class::Accessor::Fast this module provides a faster less-flexible chained accessor maker. =head1 AUTHOR Richard Clamp =head1 COPYRIGHT Copyright (C) 2003 Richard Clamp. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L =cut Class-Accessor-Chained-0.01/lib/Class/Accessor/Chained.pm0100444000175000017500000000320207760412540023157 0ustar richardcrichardcuse strict; package Class::Accessor::Chained; use base 'Class::Accessor'; our $VERSION = '0.01'; sub make_accessor { my($class, $field) = @_; # Build a closure around $field. return sub { my($self) = shift; if (@_) { $self->set($field, @_); return $self; } else { return $self->get($field); } }; } sub make_wo_accessor { my($class, $field) = @_; return sub { my($self) = shift; unless (@_) { my $caller = caller; require Carp; Carp::croak("'$caller' cannot access the value of '$field' on ". "objects of class '$class'"); } else { $self->set($field, @_); return $self; } }; } 1; __END__ =head1 NAME Class::Accessor::Chained - make chained accessors =head1 SYNOPSIS package Foo; use base qw( Class::Accessor::Chained ); __PACKAGE__->mk_accessors(qw( foo bar baz )); my $foo = Foo->new->foo(1)->bar(2)->baz(4); print $foo->bar; # prints 2 =head1 DESCRIPTION A chained accessor is one that always returns the object when called with parameters (to set), and the value of the field when called with no arguments. This module subclasses Class::Accessor in order to provide the same mk_accessors interface. =head1 AUTHOR Richard Clamp =head1 COPYRIGHT Copyright (C) 2003 Richard Clamp. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L =cut Class-Accessor-Chained-0.01/META.yml0100444000175000017500000000062507760415174017176 0ustar richardcrichardc--- #YAML:1.0 name: Class-Accessor-Chained version: 0.01 license: perl distribution_type: module requires: Class::Accessor: 0 recommends: {} build_requires: Test::More: 0 conflicts: {} provides: Class::Accessor::Chained: file: lib/Class/Accessor/Chained.pm version: 0.01 Class::Accessor::Chained::Fast: file: lib/Class/Accessor/Chained/Fast.pm generated_by: Module::Build version 0.21 Class-Accessor-Chained-0.01/Changes0100444000175000017500000000006607760414633017216 0ustar richardcrichardc0.01 Monday 24th November, 2003 initial CPAN release Class-Accessor-Chained-0.01/MANIFEST0100444000175000017500000000022107760415077017050 0ustar richardcrichardcBuild.PL Changes MANIFEST Makefile.PL README META.yml lib/Class/Accessor/Chained.pm lib/Class/Accessor/Chained/Fast.pm t/00compile.t t/chained.t Class-Accessor-Chained-0.01/Build.PL0100444000175000017500000000054307760410245017212 0ustar richardcrichardcuse strict; use Module::Build; Module::Build ->new( module_name => "Class::Accessor::Chained", license => 'perl', build_requires => { 'Test::More' => 0, }, requires => { 'Class::Accessor' => 0, }, create_makefile_pl => 'traditional', ) ->create_build_script; Class-Accessor-Chained-0.01/Makefile.PL0100444000175000017500000000046207760415174017676 0ustar richardcrichardc# Generated by Module::Build::Compat->create_makefile_pl use ExtUtils::MakeMaker; WriteMakefile ( NAME => 'Class::Accessor::Chained', VERSION => '0.01', PL_FILES => {}, INSTALLDIRS => 'site', PREREQ_PM => { 'Test::More' => '0', 'Class::Accessor' => '0', }, ); Class-Accessor-Chained-0.01/README0100444000175000017500000000166207760415063016604 0ustar richardcrichardcREADME for Class::Accessor::Chained 0.01 =head1 NAME Class::Accessor::Chained - make chained accessors =head1 SYNOPSIS package Foo; use base qw( Class::Accessor::Chained ); __PACKAGE__->mk_accessors(qw( foo bar baz )); my $foo = Foo->new->foo(1)->bar(2)->baz(4); print $foo->bar; # prints 2 =head1 DEPENDENCIES This module has external dependencies on the following modules: Class::Accessor =head1 INSTALLATION perl Build.PL perl Build test and if all goes well perl Build install =head1 HISTORY What changed over the last 3 revisions =over =item 0.01 Monday 24th November, 2003 initial CPAN release =back =head1 AUTHOR Richard Clamp =head1 COPYRIGHT Copyright (C) 2003 Richard Clamp. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L