X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FStorage.pm;h=810b764cc65d6c5b31238aa5571597c8573eb749;hb=f91430591cdd881aa7bd358615be6df112aee3f9;hp=2146601d872d4d3f6e3ff84692b4e995e3c50abc;hpb=24b5691f1879ec296dce95ecb99d0b7ab166a09d;p=gitmo%2FMooseX-Storage.git diff --git a/lib/MooseX/Storage.pm b/lib/MooseX/Storage.pm index 2146601..810b764 100644 --- a/lib/MooseX/Storage.pm +++ b/lib/MooseX/Storage.pm @@ -4,7 +4,7 @@ use Moose qw(confess); use MooseX::Storage::Meta::Attribute::DoNotSerialize; -our $VERSION = '0.09'; +our $VERSION = '0.15'; our $AUTHORITY = 'cpan:STEVAN'; sub import { @@ -15,47 +15,49 @@ sub import { ($pkg->can('meta')) || confess "This package can only be used in Moose based classes"; - $pkg->meta->alias_method('Storage' => sub { - my %params = @_; + $pkg->meta->add_method('Storage' => __PACKAGE__->meta->find_method_by_name('_injected_storage_role_generator')); +} + +sub _injected_storage_role_generator { + my %params = @_; - if (exists $params{'base'}) { - $params{'base'} = ('Base::' . $params{'base'}); - } - else { - $params{'base'} = 'Basic'; - } + if (exists $params{'base'}) { + $params{'base'} = ('Base::' . $params{'base'}); + } + else { + $params{'base'} = 'Basic'; + } - my @roles = ( - ('MooseX::Storage::' . $params{'base'}), - ); + my @roles = ( + ('MooseX::Storage::' . $params{'base'}), + ); - # NOTE: - # you don't have to have a format - # role, this just means you dont - # get anything other than pack/unpack - push @roles => 'MooseX::Storage::Format::' . $params{'format'} - if exists $params{'format'}; + # NOTE: + # you don't have to have a format + # role, this just means you dont + # get anything other than pack/unpack + push @roles => 'MooseX::Storage::Format::' . $params{'format'} + if exists $params{'format'}; + # NOTE: + # many IO roles don't make sense unless + # you have also have a format role chosen + # too, the exception being StorableFile + if (exists $params{'io'}) { # NOTE: - # many IO roles don't make sense unless - # you have also have a format role chosen - # too, the exception being StorableFile - if (exists $params{'io'}) { - # NOTE: - # we dont need this code anymore, cause - # the role composition will catch it for - # us. This allows the StorableFile to work - #(exists $params{'format'}) - # || confess "You must specify a format role in order to use an IO role"; - push @roles => 'MooseX::Storage::IO::' . $params{'io'}; - } + # we dont need this code anymore, cause + # the role composition will catch it for + # us. This allows the StorableFile to work + #(exists $params{'format'}) + # || confess "You must specify a format role in order to use an IO role"; + push @roles => 'MooseX::Storage::IO::' . $params{'io'}; + } - Class::MOP::load_class($_) - || die "Could not load role (" . $_ . ") for package ($pkg)" - foreach @roles; + Class::MOP::load_class($_) + || die "Could not load role (" . $_ . ")" + foreach @roles; - return @roles; - }); + return @roles; } 1; @@ -261,7 +263,7 @@ Yuval Kogman Eyuval.kogman@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2007 by Infinity Interactive, Inc. +Copyright 2007-2008 by Infinity Interactive, Inc. L