X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader.pm;h=a68e585142fab5e36455adb40dff071c4a5d5118;hb=9ae3eecd42f2c70ee84a5322fb2754c84fae5d2c;hp=55b1398ae7464a2cadac3776f6b35d70596dde04;hpb=ba12c8acfa1dd66cbea6c9cfd40a3a33244ab6bd;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 55b1398..a68e585 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -7,16 +7,16 @@ use MRO::Compat; use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; use Scalar::Util 'weaken'; -use Sub::Name 'subname'; -use DBIx::Class::Schema::Loader::Utils 'array_eq'; +use Sub::Util 'set_subname'; +use DBIx::Class::Schema::Loader::Utils qw/array_eq sigwarn_silencer/; use Try::Tiny; -use Hash::Merge 'merge'; +use curry; use namespace::clean; # Always remember to do all digits for the version even if they're 0 # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports # brain damage and presumably various other packaging systems too -our $VERSION = '0.07042'; +our $VERSION = '0.07049'; __PACKAGE__->mk_group_accessors('inherited', qw/ _loader_args @@ -187,13 +187,13 @@ sub _invoke_loader { $args->{naming} = $self->naming if $self->naming; $args->{use_namespaces} = $self->use_namespaces if defined $self->use_namespaces; - # XXX this only works for relative storage_type, like ::DBI ... my $loader_class = $self->loader_class; if ($loader_class) { $loader_class = "DBIx::Class::Schema::Loader${loader_class}" if $loader_class =~ /^::/; $args->{loader_class} = $loader_class; }; + # XXX this only works for relative storage_type, like ::DBI ... my $impl = $loader_class || "DBIx::Class::Schema::Loader" . $self->storage_type; try { $self->ensure_class_loaded($impl) @@ -232,13 +232,28 @@ sub _merge_state_from { $self->_copy_state_from($from); - $self->class_mappings(merge($orig_class_mappings, $self->class_mappings)) + $self->class_mappings(__merge($orig_class_mappings, $self->class_mappings)) if $orig_class_mappings; - $self->source_registrations(merge($orig_source_registrations, $self->source_registrations)) + $self->source_registrations(__merge($orig_source_registrations, $self->source_registrations)) if $orig_source_registrations; } +my $merger; +sub __merge { + + local $SIG{__WARN__} = sigwarn_silencer(qr/Arguments for _merge_hashes must be hash references/); + + ( $merger ||= do { + require Hash::Merge; + my $m = Hash::Merge->new('LEFT_PRECEDENT'); + $m->set_clone_behavior(0); + $m; + } )->merge( + $_[0], $_[1] + ); +} + sub _copy_state_from { my $self = shift; my ($from) = @_; @@ -341,7 +356,7 @@ sub connection { # ->load_components and we are now in a different place in the mro. no warnings 'redefine'; - local *connection = subname __PACKAGE__.'::connection' => sub { + local *connection = set_subname __PACKAGE__.'::connection' => sub { my $self = shift; $self->next::method(@_); }; @@ -460,11 +475,11 @@ sub import { } elsif($opt eq 'naming') { no strict 'refs'; - *{"${cpkg}::naming"} = sub { $self->naming(@_) }; + *{"${cpkg}::naming"} = $self->curry::naming; } elsif($opt eq 'use_namespaces') { no strict 'refs'; - *{"${cpkg}::use_namespaces"} = sub { $self->use_namespaces(@_) }; + *{"${cpkg}::use_namespaces"} = $self->curry::use_namespaces, } } } @@ -611,84 +626,87 @@ Based on L by Sebastian Riedel Based upon the work of IKEBE Tomohiro -=head1 AUTHOR +=head1 AUTHORS -blblack: Brandon Black +Caelum: Rafael Kitover -=head1 CONTRIBUTORS +Dag-Erling Smørgrav -ilmari: Dagfinn Ilmari MannsEker +Matias E. Fernandez -arcanez: Justin Hunter +SineSwiper: Brendan Byrd -ash: Ash Berlin +TSUNODA Kazuya -btilly: Ben Tilly +acmoore: Andrew Moore -Caelum: Rafael Kitover +alnewkirk: Al Newkirk -TSUNODA Kazuya +andrewalker: André Walker -rbo: Robert Bohne +angelixd: Paul C. Mantz -ribasushi: Peter Rabbitson +arc: Aaron Crane -gugu: Andrey Kostenko +arcanez: Justin Hunter -jhannah: Jay Hannah +ash: Ash Berlin -jnap: John Napiorkowski +blblack: Brandon Black -rbuels: Robert Buels +bphillips: Brian Phillips -timbunce: Tim Bunce +btilly: Ben Tilly -mst: Matt S. Trout +domm: Thomas Klausner -mstratman: Mark A. Stratman +ether: Karen Etheridge -kane: Jos Boumans +gugu: Andrey Kostenko -waawaamilk: Nigel McNie +hobbs: Andrew Rodland -acmoore: Andrew Moore +ilmari: Dagfinn Ilmari MannsEker -bphillips: Brian Phillips +jhannah: Jay Hannah -schwern: Michael G. Schwern +jnap: John Napiorkowski -SineSwiper: Brendan Byrd +kane: Jos Boumans -hobbs: Andrew Rodland +mattp: Matt Phillips -domm: Thomas Klausner +mephinet: Philipp Gortan -spb: Stephen Bennett +moritz: Moritz Lenz -Matias E. Fernandez +mst: Matt S. Trout -alnewkirk: Al Newkirk +mstratman: Mark A. Stratman -angelixd: Paul C. Mantz +oalders: Olaf Alders -andrewalker: André Walker +rbo: Robert Bohne -mattp: Matt Phillips +rbuels: Robert Buels -Dag-Erling Smørgrav +ribasushi: Peter Rabbitson -moritz: Moritz Lenz +schwern: Michael G. Schwern -oalders: Olaf Alders +spb: Stephen Bennett + +timbunce: Tim Bunce + +waawaamilk: Nigel McNie ... and lots of other folks. If we forgot you, please write the current maintainer or RT. =head1 COPYRIGHT & LICENSE -Copyright (c) 2006 - 2009 by the aforementioned -L and -L. +Copyright (c) 2006 - 2015 by the aforementioned +L. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.