From: Chris Nehren Date: Mon, 25 Jul 2011 19:57:55 +0000 (-0400) Subject: port to Moo X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8a5453ad566903497b1845b41ea1c9cfc9c8cb73;p=p5sagit%2FEmail-Archive.git port to Moo --- diff --git a/lib/Email/Archive.pm b/lib/Email/Archive.pm index 382e3c3..8d17fcb 100644 --- a/lib/Email/Archive.pm +++ b/lib/Email/Archive.pm @@ -1,5 +1,5 @@ package Email::Archive; -use Moose; +use Moo; use Email::Archive::Storage::DBI; our $VERSION = '0.02'; diff --git a/lib/Email/Archive/Storage.pm b/lib/Email/Archive/Storage.pm index f6bbc3d..0f18052 100644 --- a/lib/Email/Archive/Storage.pm +++ b/lib/Email/Archive/Storage.pm @@ -1,5 +1,5 @@ package Email::Archive::Storage; -use Moose::Role; +use Moo::Role; requires qw/store retrieve search storage_connect/; 1; diff --git a/lib/Email/Archive/Storage/DBI.pm b/lib/Email/Archive/Storage/DBI.pm index 9f6baa4..3ee81f6 100644 --- a/lib/Email/Archive/Storage/DBI.pm +++ b/lib/Email/Archive/Storage/DBI.pm @@ -1,5 +1,5 @@ package Email::Archive::Storage::DBI; -use Moose; +use Moo; use Carp; use DBI; use File::ShareDir 'module_file'; @@ -7,12 +7,15 @@ use File::Slurp 'read_file'; use Email::MIME; use Email::Abstract; use SQL::Abstract; +use Scalar::Util qw(looks_like_number); use autodie; with q/Email::Archive::Storage/; has sqla => ( is => 'ro', - isa => 'SQL::Abstract', + isa => sub { + ref $_[0] eq 'SQL::Abstract' or die "sqla must be a SQL::Abstract object" + }, lazy => 1, default => sub { SQL::Abstract->new }, handles => [qw/ @@ -23,7 +26,9 @@ has sqla => ( has dbh => ( is => 'rw', - isa => 'DBI::db', + isa => sub { + ref $_[0] eq 'DBI::db' or die "dbh must be a DBI handle", + }, handles => [qw/ prepare do @@ -32,7 +37,9 @@ has dbh => ( has deployed_schema_version => ( is => 'rw', - isa => 'Int', + isa => sub { + looks_like_number($_[0]) or die "deployed_schema_version must be integer" + }, default => 0, );