From: Peter Rabbitson Date: Wed, 29 Jun 2016 13:32:00 +0000 (+0200) Subject: Expand signature of describe_class_methods for forward compat X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8eac247d3f1150abf238ae6a119860cdc8cf02b9;p=dbsrgits%2FDBIx-Class.git Expand signature of describe_class_methods for forward compat It is likely extra options/attrs will need to be passed down the road - hence do not lock ourselves into positional args --- diff --git a/lib/DBIx/Class/_Util.pm b/lib/DBIx/Class/_Util.pm index 7af2102..1c9c4b0 100644 --- a/lib/DBIx/Class/_Util.pm +++ b/lib/DBIx/Class/_Util.pm @@ -675,9 +675,15 @@ sub modver_gt_or_eq_and_lt ($$$) { our $describe_class_query_cache; sub describe_class_methods { - my ($class, $requested_mro) = @_; + my $args = ( + ref $_[0] eq 'HASH' ? $_[0] + : ( @_ == 1 and ! length ref $_[0] ) ? { class => $_[0] } + : { @_ } + ); + + my ($class, $requested_mro) = @{$args}{qw( class use_mro )}; - croak "Expecting a class name" + croak "Expecting a class name either as the sole argument or a 'class' option" if not defined $class or $class !~ $module_name_rx; $requested_mro ||= mro::get_mro($class); diff --git a/xt/extra/internals/attributes.t b/xt/extra/internals/attributes.t index 6567ec6..2717b00 100644 --- a/xt/extra/internals/attributes.t +++ b/xt/extra/internals/attributes.t @@ -449,7 +449,7 @@ sub add_more_attrs { is_deeply ( # work around taint, see TODO below { - %{describe_class_methods("DBICTest::AttrTest", "dfs")}, + %{ describe_class_methods({ class => "DBICTest::AttrTest", use_mro => "dfs" }) }, cumulative_gen => $expected_desc->{cumulative_gen}, }, $expected_desc,