File Coverage

blib/lib/DBIx/Class/Schema/Diff/State.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package DBIx::Class::Schema::Diff::State;
2 5     5   37 use strict;
  5         15  
  5         174  
3 5     5   27 use warnings;
  5         12  
  5         146  
4              
5             # ABSTRACT: Diff object of a single schema
6              
7 5     5   27 use Moo;
  5         11  
  5         37  
8             extends 'DBIx::Class::Schema::Diff';
9             #with 'DBIx::Class::Schema::Diff::Role::Common';
10              
11             require DBIx::Class::Schema::Diff::Schema;
12              
13 5     5   2135 use Types::Standard qw(:all);
  5         12  
  5         51  
14              
15             has 'schema', is => 'ro', isa => Maybe[Str], default => sub { undef };
16              
17             has '_schema_diff', required => 1, is => 'ro', isa => InstanceOf['DBIx::Class::Schema::Diff::Schema'];
18              
19             around BUILDARGS => sub {
20             my ($orig, $self, @args) = @_;
21             my %opt = (ref($args[0]) eq 'HASH') ? %{ $args[0] } : @args; # <-- arg as hash or hashref
22            
23             die "Must supply single 'schema' not old_schema and new_schema" if ($opt{new_schema} || $opt{old_schema});
24            
25             unless($opt{_schema_diff}) {
26             my $schema = $opt{schema} or die "schema argument required";
27             $opt{_schema_diff} = DBIx::Class::Schema::Diff::Schema->new(
28             new_schema => $schema,
29             old_schema => $schema,
30             new_schema_only => 1
31             )
32             }
33            
34             return $self->$orig(%opt)
35             };
36              
37              
38              
39             1;
40              
41              
42             __END__