###########################################################################
use 5.10.1;
-use strict;
-use warnings;
+use Moo;
use Bugzilla::Error;
use Bugzilla::Hook;
=cut
#--------------------------------------------------------------------------
-sub new {
+sub BUILD {
+ my $self = shift;
+ my $class = ref($self) || $self;
-=over
-
-=item C<new>
-
- Description: Public constructor method used to instantiate objects of this
- class.
- Parameters: $schema (optional) - A reference to a hash. Callers external
- to this package should never use this parameter.
- Returns: new instance of the Schema class or a database-specific subclass
+ die "$class is an abstract base class. Instantiate a subclass instead."
+ if ($class eq __PACKAGE__);
-=cut
+ $self->_initialize();
+} #eosub--BUILD
- my $this = shift;
- my $class = ref($this) || $this;
+# we declare attributes below, even though we access their slots directly.
+# This is because this code is evolving from the pre-Moo days of perl OO.
- die "$class is an abstract base class. Instantiate a subclass instead."
- if ($class eq __PACKAGE__);
+# the init_arg begins with an underscore as this should only be passed in internally.
+# This should be a 'lazy' attribute, but to maintain the smallest diff we're
+# instead setting it in _initialize() if it isn't already passed in.
+has 'abstract_schema' => ( init_arg => '_abstract_schema', is => 'rw' );
- my $self = {};
- bless $self, $class;
- $self = $self->_initialize(@_);
+# this could also be lazy, but it is also set in _initialize()
+has 'schema' => (init_arg =>undef, is => 'rw');
- return ($self);
+has 'db_specific' => (init_arg => undef, is => 'rw');
-} #eosub--new
#--------------------------------------------------------------------------
sub _initialize {
define the database-specific implementation of the all
abstract data types), and then call the C<_adjust_schema>
method.
- Parameters: $abstract_schema (optional) - A reference to a hash. If
- provided, this hash will be used as the internal
- representation of the abstract schema instead of our
- default abstract schema. This is intended for internal
- use only by deserialize_abstract.
Returns: the instance of the Schema class
=cut
my $self = shift;
- my $abstract_schema = shift;
+ my $abstract_schema = $self->abstract_schema;
if (!$abstract_schema) {
}
}
- return $class->new($thawed_hash);
+ return $class->new(_abstract_schema => $thawed_hash);
}
#####################################################################
###############################################################################
use 5.10.1;
-use strict;
-use warnings;
+use Moo;
use Bugzilla::Error;
-use base qw(Bugzilla::DB::Schema);
+extends qw(Bugzilla::DB::Schema);
# This is for column_info_to_column, to know when a tinyint is a
# boolean and when it's really a tinyint. This only has to be accurate
my $self = shift;
- $self = $self->SUPER::_initialize(@_);
+ $self = $self->SUPER::_initialize();
$self->{db_specific} = {
###############################################################################
use 5.10.1;
-use strict;
-use warnings;
+use Moo;
-use base qw(Bugzilla::DB::Schema);
+extends qw(Bugzilla::DB::Schema);
use Storable qw(dclone);
#------------------------------------------------------------------------------
my $self = shift;
- $self = $self->SUPER::_initialize(@_);
+ $self = $self->SUPER::_initialize();
# Remove FULLTEXT index types from the schemas.
foreach my $table (keys %{$self->{schema}}) {