X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FComponent.pm;h=8fe109feb9a101dfa469aba9c26014b3d35a486a;hp=55f25c0092ec598d69484baabe728a53db37af47;hb=dd4530ecdc4684838d9c0e9dc00adebb6100b022;hpb=e58865461d2d7c80b8136a4b853082cb8031975e diff --git a/lib/Catalyst/Component.pm b/lib/Catalyst/Component.pm index 55f25c0..8fe109f 100644 --- a/lib/Catalyst/Component.pm +++ b/lib/Catalyst/Component.pm @@ -11,6 +11,7 @@ use mro 'c3'; use Scalar::Util 'blessed'; use Class::Load 'is_class_loaded'; use Moose::Util 'find_meta'; +use Ref::Util qw(is_plain_hashref); use namespace::clean -except => 'meta'; with 'MooseX::Emulate::Class::Accessor::Fast'; @@ -91,12 +92,12 @@ sub BUILDARGS { my $args = {}; if (@_ == 1) { - $args = $_[0] if ref($_[0]) eq 'HASH'; + $args = $_[0] if is_plain_hashref($_[0]); } elsif (@_ == 2) { # is it ($app, $args) or foo => 'bar' ? if (blessed($_[0])) { - $args = $_[1] if ref($_[1]) eq 'HASH'; + $args = $_[1] if is_plain_hashref($_[1]); } elsif (is_class_loaded($_[0]) && - $_[0]->isa('Catalyst') && ref($_[1]) eq 'HASH') { + $_[0]->isa('Catalyst') && is_plain_hashref($_[1])) { $args = $_[1]; } else { $args = +{ @_ }; @@ -112,7 +113,7 @@ sub COMPONENT { my ( $class, $c ) = @_; # Temporary fix, some components does not pass context to constructor - my $arguments = ( ref( $_[-1] ) eq 'HASH' ) ? $_[-1] : {}; + my $arguments = is_plain_hashref($_[-1]) ? $_[-1] : {}; if ( my $next = $class->next::can ) { my ($next_package) = Class::MOP::get_code_info($next); warn "There is a COMPONENT method resolving after Catalyst::Component in ${next_package}.\n";