From: Tomas Doran Date: Sat, 21 Mar 2009 14:08:25 +0000 (+0000) Subject: Merge up ashs r9505 from 5.70 X-Git-Tag: 5.80001~61 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=7033c56c02869e4c4950f4861c7ae3cf118b42c1 Merge up ashs r9505 from 5.70 --- 7033c56c02869e4c4950f4861c7ae3cf118b42c1 diff --cc lib/Catalyst/Dispatcher.pm index 08652e5,e8e201e..e5b3d22 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@@ -636,52 -629,20 +641,66 @@@ sub _load_dispatch_types return @loaded; } +use Moose; + +# 5.70 backwards compatibility hacks. + +# Various plugins (e.g. Plugin::Server and Plugin::Authorization::ACL) +# need the methods here which *should* be private.. + +# However we can't really take them away until there is a sane API for +# building actions and configuring / introspecting the dispatcher. +# In 5.90, we should build that infrastructure, port the plugins which +# use it, and then take the crap below away. +# See also t/lib/TestApp/Plugin/AddDispatchTypes.pm + +# Alias _method_name to method_name, add a before modifier to warn.. +foreach my $public_method_name (qw/ + tree + dispatch_types + registered_dispatch_types + method_action_class + action_hash + container_hash + /) { + my $private_method_name = '_' . $public_method_name; + my $meta = __PACKAGE__->meta; # Calling meta method here fine as we happen at compile time. + $meta->add_method($public_method_name, $meta->get_method($private_method_name)); + { + my %package_hash; # Only warn once per method, per package. These are infrequent enough that + # I haven't provided a way to disable them, patches welcome. + $meta->add_before_method_modifier($public_method_name, sub { + my $class = blessed(shift); + $package_hash{$class}++ || do { + warn("Class $class is calling the deprecated method Catalyst::Dispatcher::$public_method_name,\n" + . "this will be removed in Catalyst 5.9X"); + }; + }); + } +} +# End 5.70 backwards compatibility hacks. + +no Moose; +__PACKAGE__->meta->make_immutable; + +=head2 meta + +Provided by Moose + + # Dont document this until someone else is happy with beaviour. Ash 2009/03/16 + sub dispatch_type { + my ($self, $name) = @_; + + unless ($name =~ s/^\+//) { + $name = "Catalyst::DispatchType::" . $name; + } + + for (@{ $self->dispatch_types }) { + return $_ if ref($_) eq $name; + } + return undef; + } + =head1 AUTHORS Catalyst Contributors, see Catalyst.pm