}
use JSON::Any qw(DWIW PP JSON CPANEL XS);
-use Moose;
-use MooseX::Types::Moose qw/Int Str Any Bool/;
-use DBIx::Class::Admin::Types qw/DBICConnectInfo DBICHashRef/;
-use MooseX::Types::JSON qw(JSON);
-use MooseX::Types::Path::Class qw(Dir File);
-use MooseX::Types::LoadableClass qw(LoadableClass);
+use Moo;
+use Type::Utils qw(class_type);
+use Types::Standard qw(Int Str Any Bool);
+use DBIx::Class::Admin::Types qw(Dir File DBICConnectInfo DBICHashRef);
+use Types::LoadableClass qw(LoadableClass);
use Try::Tiny;
use namespace::clean;
has 'schema' => (
is => 'ro',
- isa => 'DBIx::Class::Schema',
- lazy_build => 1,
+ isa => class_type('DBIx::Class::Schema'),
+ lazy => 1,
+ builder => 1,
+ predicate => 1,
+ clearer => 1,
);
sub _build_schema {
has 'connect_info' => (
is => 'ro',
isa => DBICConnectInfo,
- lazy_build => 1,
+ lazy => 1,
+ builder => 1,
+ predicate => 1,
+ clearer => 1,
coerce => 1,
);
has config => (
is => 'ro',
isa => DBICHashRef,
- lazy_build => 1,
+ lazy => 1,
+ builder => 1,
+ predicate => 1,
+ clearer => 1,
);
sub _build_config {
isa => Bool,
);
-has '_confirm' => (
- is => 'bare',
- isa => Bool,
-);
-
-
=head2 trace
Toggle DBIx::Class debug output
sub _confirm {
my ($self) = @_;
- # mainly here for testing
- return 1 if ($self->meta->get_attribute('_confirm')->get_value($self));
-
print "Are you sure you want to do this? (type YES to confirm) \n";
my $response = <STDIN>;
package # hide from PAUSE
DBIx::Class::Admin::Types;
-# Workaround for https://rt.cpan.org/Public/Bug/Display.html?id=83336
use warnings;
use strict;
-use MooseX::Types -declare => [qw(
+use Type::Library
+ -base,
+ -declare => qw(
+ Dir File
DBICConnectInfo
DBICArrayRef
DBICHashRef
-)];
-use MooseX::Types::Moose qw/Int HashRef ArrayRef Str Any Bool/;
-use MooseX::Types::JSON qw(JSON);
+);
+use Type::Utils -all;
+use Types::Standard qw/HashRef ArrayRef Str/;
+use Path::Class;
+
+class_type Dir, { class => 'Path::Class::Dir' };
+class_type File, { class => 'Path::Class::File' };
+
+coerce Dir, from Str, via { dir($_) };
+coerce File, from Str, via { file($_) };
subtype DBICArrayRef,
as ArrayRef;
as HashRef;
coerce DBICArrayRef,
- from JSON,
+ from Str,
via { _json_to_data ($_) };
coerce DBICHashRef,
- from JSON,
+ from Str,
via { _json_to_data($_) };
subtype DBICConnectInfo,
as ArrayRef;
coerce DBICConnectInfo,
- from JSON,
- via { return _json_to_data($_) } ;
-
-coerce DBICConnectInfo,
- from Str,
- via { return _json_to_data($_) };
-
-coerce DBICConnectInfo,
- from HashRef,
- via { [ $_ ] };
+ from Str, via { _json_to_data($_) },
+ from HashRef, via { [ $_ ] };
sub _json_to_data {
my ($json_str) = @_;
+ require JSON::Any;
my $json = JSON::Any->new(allow_barekey => 1, allow_singlequote => 1, relaxed=>1);
my $ret = $json->jsonToObj($json_str);
return $ret;
# POD is generated automatically by calling _gen_pod from the
# Makefile.PL in $AUTHOR mode
-# *DELIBERATELY* not making a group for these - they must disappear
-# forever as optdeps in the first place
-my $moose_basic = {
- 'Moose' => '0.98',
- 'MooseX::Types' => '0.21',
- 'MooseX::Types::LoadableClass' => '0.011',
-};
-
my $dbic_reqs = {
# NOTE: the rationale for 2 JSON::Any versions is that
},
admin => {
- include => '_json_any',
- req => {
- %$moose_basic,
- 'MooseX::Types::Path::Class' => '0.05',
- 'MooseX::Types::JSON' => '0.02',
- },
+ include => [qw(_json_any _types_common)],
pod => {
title => 'DBIx::Class::Admin',
desc => 'Modules required for the DBIx::Class administrative library',
use DBIx::Class::_Util 'sigwarn_silencer';
use DBIx::Class::Admin;
+BEGIN {
+ no warnings 'redefine';
+ # no questions asked
+ sub DBIx::Class::Admin::_confirm { 1 };
+}
# lock early
DBICTest->init_schema(no_deploy => 1, no_populate => 1);
my $admin = DBIx::Class::Admin->new(
schema_class => 'DBICVersion::Schema',
sql_dir => $ddl_dir,
- _confirm => 1,
connect_info => \@connect_info,
);
use DBICTest;
use DBIx::Class::Admin;
+BEGIN {
+ no warnings 'redefine';
+ # no questions asked
+ sub DBIx::Class::Admin::_confirm { 1 };
+}
{ # test data maniplulation functions
'DBIx::Class::Admin' => {
ignore => [ qw/
BUILD
+ has_config
+ has_connect_info
+ has_schema
/]
},