X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FAccessor%2FGrouped.pm;h=77c55750f8b52af306d267b843cf43a83a227233;hb=18922520eb03bc7fb5e1cdfd7304748365b7210e;hp=aea38c20774f28c7ab28ccff7cf2d3e52792b9fe;hpb=b36cd2595cc422d4e5bb0d5e905acfd7d4c1fd70;p=p5sagit%2FClass-Accessor-Grouped.git diff --git a/lib/Class/Accessor/Grouped.pm b/lib/Class/Accessor/Grouped.pm index aea38c2..77c5575 100644 --- a/lib/Class/Accessor/Grouped.pm +++ b/lib/Class/Accessor/Grouped.pm @@ -3,9 +3,17 @@ use strict; use warnings; use Carp (); use Scalar::Util (); -use MRO::Compat; -our $VERSION = '0.10001'; +BEGIN { + if ($] < 5.009_005) { + require MRO::Compat; + } + else { + require mro; + } +} + +our $VERSION = '0.10002'; $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases # when changing minimum version don't forget to adjust L and @@ -72,6 +80,14 @@ Class::Accessor::Grouped - Lets you build groups of accessors =head1 SYNOPSIS + use base 'Class::Accessor::Grouped'; + + # make basic accessors for objects + __PACKAGE__->mk_group_accessors(simple => qw(id name email)); + + # make accessor that works for objects and classes + __PACKAGE__->mk_group_accessors(inherited => 'awesome_level'); + =head1 DESCRIPTION This class lets you build groups of accessors that will call different @@ -81,6 +97,8 @@ getters and setters. =head2 mk_group_accessors + __PACKAGE__->mk_group_accessors(simple => 'hair_length'); + =over 4 =item Arguments: $group, @fieldspec @@ -113,6 +131,8 @@ sub mk_group_accessors { =head2 mk_group_ro_accessors + __PACKAGE__->mk_group_ro_accessors(simple => 'birthdate'); + =over 4 =item Arguments: $group, @fieldspec @@ -135,6 +155,8 @@ sub mk_group_ro_accessors { =head2 mk_group_wo_accessors + __PACKAGE__->mk_group_wo_accessors(simple => 'lie'); + =over 4 =item Arguments: $group, @fieldspec @@ -157,6 +179,8 @@ sub mk_group_wo_accessors { =head2 make_group_accessor + __PACKAGE__->make_group_accessor(simple => 'hair_length', 'hair_length'); + =over 4 =item Arguments: $group, $field, $method @@ -175,6 +199,8 @@ sub make_group_accessor { $gen_accessor->('rw', @_) } =head2 make_group_ro_accessor + __PACKAGE__->make_group_ro_accessor(simple => 'birthdate', 'birthdate'); + =over 4 =item Arguments: $group, $field, $method @@ -193,6 +219,8 @@ sub make_group_ro_accessor { $gen_accessor->('ro', @_) } =head2 make_group_wo_accessor + __PACKAGE__->make_group_wo_accessor(simple => 'lie', 'lie'); + =over 4 =item Arguments: $group, $field, $method @@ -463,6 +491,8 @@ Christopher H. Laco Caelum: Rafael Kitover +frew: Arthur Axel "fREW" Schmidt + groditi: Guillermo Roditi Jason Plum @@ -689,7 +719,7 @@ $gen_accessor = sub { # if after this shim was created someone wrapped it with an 'around', # we can not blindly reinstall the method slot - we will destroy the # wrapper. Silently chain execution further... - if ($expected_cref != $current_class->can($methname)) { + if ( !$expected_cref or $expected_cref != $current_class->can($methname) ) { # there is no point in re-determining it on every subsequent call, # just store for future reference