From: Dagfinn Ilmari Mannsåker Date: Sat, 3 Jan 2015 16:52:39 +0000 (+0000) Subject: Use consistent 4-space indentation in lib/ X-Git-Tag: 0.07043~26 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=83bce685261042f92421f313dd724a910c8d8f0e;hp=51719c5f11b1e7bc844056f4be13c3fcb3c75a64;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Use consistent 4-space indentation in lib/ --- diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 40b04f5..d3ee1ef 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -37,49 +37,49 @@ DBIx::Class::Schema::Loader - Create a DBIx::Class::Schema based on a database =head1 SYNOPSIS - ### use this module to generate a set of class files - - # in a script - use DBIx::Class::Schema::Loader qw/ make_schema_at /; - make_schema_at( - 'My::Schema', - { debug => 1, - dump_directory => './lib', - }, - [ 'dbi:Pg:dbname="foo"', 'myuser', 'mypassword', - { loader_class => 'MyLoader' } # optionally - ], - ); - - # from the command line or a shell script with dbicdump (distributed - # with this module). Do `perldoc dbicdump` for usage. - dbicdump -o dump_directory=./lib \ - -o components='["InflateColumn::DateTime"]' \ - -o debug=1 \ - My::Schema \ - 'dbi:Pg:dbname=foo' \ - myuser \ - mypassword - - ### or generate and load classes at runtime - # note: this technique is not recommended - # for use in production code - - package My::Schema; - use base qw/DBIx::Class::Schema::Loader/; - - __PACKAGE__->loader_options( - constraint => '^foo.*', - # debug => 1, - ); - - #### in application code elsewhere: - - use My::Schema; - - my $schema1 = My::Schema->connect( $dsn, $user, $password, $attrs); - # -or- - my $schema1 = "My::Schema"; $schema1->connection(as above); + ### use this module to generate a set of class files + + # in a script + use DBIx::Class::Schema::Loader qw/ make_schema_at /; + make_schema_at( + 'My::Schema', + { debug => 1, + dump_directory => './lib', + }, + [ 'dbi:Pg:dbname="foo"', 'myuser', 'mypassword', + { loader_class => 'MyLoader' } # optionally + ], + ); + + # from the command line or a shell script with dbicdump (distributed + # with this module). Do `perldoc dbicdump` for usage. + dbicdump -o dump_directory=./lib \ + -o components='["InflateColumn::DateTime"]' \ + -o debug=1 \ + My::Schema \ + 'dbi:Pg:dbname=foo' \ + myuser \ + mypassword + + ### or generate and load classes at runtime + # note: this technique is not recommended + # for use in production code + + package My::Schema; + use base qw/DBIx::Class::Schema::Loader/; + + __PACKAGE__->loader_options( + constraint => '^foo.*', + # debug => 1, + ); + + #### in application code elsewhere: + + use My::Schema; + + my $schema1 = My::Schema->connect( $dsn, $user, $password, $attrs); + # -or- + my $schema1 = "My::Schema"; $schema1->connection(as above); =head1 DESCRIPTION diff --git a/lib/DBIx/Class/Schema/Loader/DBI/ADO.pm b/lib/DBIx/Class/Schema/Loader/DBI/ADO.pm index 9048290..52b0666 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/ADO.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/ADO.pm @@ -20,21 +20,21 @@ See L for usage information. =cut sub _rebless { - my $self = shift; - - return if ref $self ne __PACKAGE__; - - my $dbh = $self->schema->storage->dbh; - my $dbtype = eval { $dbh->get_info(17) }; - unless ( $@ ) { - # Translate the backend name into a perl identifier - $dbtype =~ s/\W/_/gi; - my $class = "DBIx::Class::Schema::Loader::DBI::ADO::${dbtype}"; - if ($self->load_optional_class($class) && !$self->isa($class)) { - bless $self, $class; - $self->_rebless; + my $self = shift; + + return if ref $self ne __PACKAGE__; + + my $dbh = $self->schema->storage->dbh; + my $dbtype = eval { $dbh->get_info(17) }; + unless ( $@ ) { + # Translate the backend name into a perl identifier + $dbtype =~ s/\W/_/gi; + my $class = "DBIx::Class::Schema::Loader::DBI::ADO::${dbtype}"; + if ($self->load_optional_class($class) && !$self->isa($class)) { + bless $self, $class; + $self->_rebless; + } } - } } sub _filter_tables { diff --git a/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm b/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm index d91f169..6a777a7 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm @@ -22,22 +22,22 @@ See L for usage information. =cut sub _rebless { - my $self = shift; - - return if ref $self ne __PACKAGE__; - -# stolen from DBIC ODBC storage - my $dbh = $self->schema->storage->dbh; - my $dbtype = eval { $dbh->get_info(17) }; - unless ( $@ ) { - # Translate the backend name into a perl identifier - $dbtype =~ s/\W/_/gi; - my $class = "DBIx::Class::Schema::Loader::DBI::ODBC::${dbtype}"; - if ($self->load_optional_class($class) && !$self->isa($class)) { - bless $self, $class; - $self->_rebless; + my $self = shift; + + return if ref $self ne __PACKAGE__; + + # stolen from DBIC ODBC storage + my $dbh = $self->schema->storage->dbh; + my $dbtype = eval { $dbh->get_info(17) }; + unless ( $@ ) { + # Translate the backend name into a perl identifier + $dbtype =~ s/\W/_/gi; + my $class = "DBIx::Class::Schema::Loader::DBI::ODBC::${dbtype}"; + if ($self->load_optional_class($class) && !$self->isa($class)) { + bless $self, $class; + $self->_rebless; + } } - } } =head1 SEE ALSO diff --git a/lib/DBIx/Class/Schema/Loader/Utils.pm b/lib/DBIx/Class/Schema/Loader/Utils.pm index c2e5d43..fca3c2f 100644 --- a/lib/DBIx/Class/Schema/Loader/Utils.pm +++ b/lib/DBIx/Class/Schema/Loader/Utils.pm @@ -52,13 +52,13 @@ sub dumper_squashed($) { # copied from DBIx::Class::_Util, import from there once it's released sub sigwarn_silencer { - my $pattern = shift; + my $pattern = shift; - croak "Expecting a regexp" if ref $pattern ne 'Regexp'; + croak "Expecting a regexp" if ref $pattern ne 'Regexp'; - my $orig_sig_warn = $SIG{__WARN__} || sub { CORE::warn(@_) }; + my $orig_sig_warn = $SIG{__WARN__} || sub { CORE::warn(@_) }; - return sub { &$orig_sig_warn unless $_[0] =~ $pattern }; + return sub { &$orig_sig_warn unless $_[0] =~ $pattern }; } sub eval_package_without_redefine_warnings {