From: Justin Hunter Date: Mon, 15 Jun 2009 21:35:53 +0000 (-0700) Subject: formatting changes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=109263d02704d72c51cdbafe33eeb882db598728;p=dbsrgits%2FSQL-Translator-2.0-ish.git formatting changes move from ArrayRef to HashRef typo fixes --- diff --git a/lib/SQL/Translator/Object/Column.pm b/lib/SQL/Translator/Object/Column.pm index 4ab81f3..2badd35 100644 --- a/lib/SQL/Translator/Object/Column.pm +++ b/lib/SQL/Translator/Object/Column.pm @@ -4,12 +4,48 @@ use MooseX::Types::Moose qw(Bool Int Str); use SQL::Translator::Types qw(Trigger); extends 'SQL::Translator::Object'; -has 'name' => (is => 'ro', isa => Str, required => 1); -has 'type' => (is => 'ro', isa => Str, required => 1); -has 'size' => (is => 'ro', isa => Int, required => 1); -has 'is_nullable' => (is => 'ro', isa => Bool, required => 1, default => 1); -has 'is_auto_increment' => (is => 'ro', isa => Bool, required => 1, default => 0); -has 'default_value' => (is => 'ro', isa => Str, required => 0); -has 'trigger' => (is => 'ro', isa => Trigger, required => 0); +has 'name' => ( + is => 'ro', + isa => Str, + required => 1 +); + +has 'type' => ( + is => 'ro', + isa => Str, + required => 1 +); + +has 'size' => ( + is => 'ro', + isa => Int, + required => 1 +); + +has 'is_nullable' => ( + is => 'ro', + isa => Bool, + required => 1, + default => 1 +); + +has 'is_auto_increment' => ( + is => 'ro', + isa => Bool, + required => 1, + default => 0 +); + +has 'default_value' => ( + is => 'ro', + isa => Str, + required => 0 +); + +has 'trigger' => ( + is => 'ro', + isa => Trigger, + required => 0 +); 1; diff --git a/lib/SQL/Translator/Object/Constraint.pm b/lib/SQL/Translator/Object/Constraint.pm index f7458ad..b3b0674 100644 --- a/lib/SQL/Translator/Object/Constraint.pm +++ b/lib/SQL/Translator/Object/Constraint.pm @@ -1,11 +1,25 @@ package SQL::Translator::Object::Constraint; use Moose; -use MooseX::Types::Moose qw(ArrayRef Str); +use MooseX::Types::Moose qw(HashRef Str); use SQL::Translator::Types qw(Column); extends 'SQL::Translator::Object'; -has 'name' => (is => 'ro', isa => Str, required => 1); -has 'columns' => (is => 'ro', isa => ArrayRef[Column], required => 1); -has 'type' => (is => 'ro', isa => Str, required => 1); +has 'name' => ( + is => 'rw', + isa => Str, + required => 1 +); + +has 'columns' => ( + is => 'rw', + isa => HashRef[Column], + required => 1 +); + +has 'type' => ( + is => 'rw', + isa => Str, + required => 1 +); 1; diff --git a/lib/SQL/Translator/Object/Index.pm b/lib/SQL/Translator/Object/Index.pm index ff84642..ffe5e74 100644 --- a/lib/SQL/Translator/Object/Index.pm +++ b/lib/SQL/Translator/Object/Index.pm @@ -1,11 +1,25 @@ package SQL::Translator::Object::Index; use Moose; -use MooseX::Types::Moose qw(ArrayRef Str); +use MooseX::Types::Moose qw(HashRef Str); use SQL::Translator::Types qw(Column); extends 'SQL::Translator::Object'; -has 'name' => (is => 'ro', isa => Str, required => 1); -has 'columns' => (is => 'ro', isa => ArrayRef[Column], required => 1); -has 'type' => (is => 'ro', isa => Str, required => 1); +has 'name' => ( + is => 'rw', + isa => Str, + required => 1 +); + +has 'columns' => ( + is => 'rw', + isa => HashRef[Column], + required => 1 +); + +has 'type' => ( + is => 'rw', + isa => Str, + required => 1 +); 1; diff --git a/lib/SQL/Translator/Object/Procedure.pm b/lib/SQL/Translator/Object/Procedure.pm index 07397bd..945eaee 100644 --- a/lib/SQL/Translator/Object/Procedure.pm +++ b/lib/SQL/Translator/Object/Procedure.pm @@ -1,15 +1,45 @@ package SQL::Translator::Object::Procedure; use Moose; -use MooseX::Types::Moose qw(Str); +use MooseX::Types::Moose qw(HashRef Int Str); use SQL::Translator::Types qw(); use SQL::Translator::Object::Schema; extends 'SQL::Translator::Object'; -has 'name' => (is => 'ro', isa => Str, required => 1); -has 'contents' => (is => 'ro', isa => Str, required => 1); -has 'parameters' => (is => 'ro', isa => Maybe[ArrayRef[Int|Str]], required => 0); -has 'owner' => (is => 'ro', isa => Str, required => 1); -has 'comments' => (is => 'ro', isa => Str, required => 0); -has 'schema' => (is => 'ro', isa => Schema, required => 1, default => sub { SQL::Translator::Object::Schema->new }); +has 'name' => ( + is => 'rw', + isa => Str, + required => 1 +); + +has 'contents' => ( + is => 'rw', + isa => Str, + required => 1 +); + +has 'parameters' => ( + is => 'rw', + isa => Maybe[HashRef[Int|Str]], + required => 0 +); + +has 'owner' => ( + is => 'rw', + isa => Str, + required => 1 +); + +has 'comments' => ( + is => 'rw', + isa => Str, + required => 0 +); + +has 'schema' => ( + is => 'rw', + isa => Schema, + required => 1, + default => sub { SQL::Translator::Object::Schema->new } +); 1; diff --git a/lib/SQL/Translator/Object/Schema.pm b/lib/SQL/Translator/Object/Schema.pm index 411bc20..cc82b13 100644 --- a/lib/SQL/Translator/Object/Schema.pm +++ b/lib/SQL/Translator/Object/Schema.pm @@ -1,12 +1,32 @@ package SQL::Translator::Object::Schema; use Moose; -use MooseX::Types::Moose qw(ArrayRef Str); +use MooseX::Types::Moose qw(HashRef Str); use SQL::Translator::Types qw(Procedure Table View); extends 'SQL::Translator::Object'; -has 'name' => (is => 'ro', isa => Str, required => 1, default => '__DEFAULT__'); -has 'tables' => (is => 'ro', isa => ArrayRef[Table], required => 0); -has 'views' => (is => 'ro', isa => ArrayRef[View], required => 0); -has 'procedures' => (is => 'ro', isa => ArrayRef[Procedure], required => 0); +has 'name' => ( + is => 'rw', + isa => Str, + required => 1, + default => '__DEFAULT__' +); + +has 'tables' => ( + is => 'rw', + isa => HashRef[Table], + required => 0 +); + +has 'views' => ( + is => 'rw', + isa => HashRef[View], + required => 0 +); + +has 'procedures' => ( + is => 'rw', + isa => HashRef[Procedure], + required => 0 +); 1; diff --git a/lib/SQL/Translator/Object/Table.pm b/lib/SQL/Translator/Object/Table.pm index 3026d40..4b795d5 100644 --- a/lib/SQL/Translator/Object/Table.pm +++ b/lib/SQL/Translator/Object/Table.pm @@ -1,14 +1,44 @@ package SQL::Translator::Object::Table; use Moose; -use MooseX::Types::Moose qw(ArrayRef Str); +use MooseX::Types::Moose qw(HashRef Str); +use MooseX::AttributeHelpers; +#use MooseX::Types::Set::Object; use SQL::Translator::Types qw(Column Constraint Index Schema); use SQL::Translator::Object::Schema; extends 'SQL::Translator::Object'; -has 'name' => (is => 'ro', isa => Str, required => 1); -has 'columns' => (is => 'ro', isa => ArrayRef[Column], required => 1); -has 'indexes' => (is => 'ro', isa => ArrayRef[Index], required => 0); -has 'constraints' => (is => 'ro', isa => ArrayRef[Constraint], required => 0); -has 'schema' => (is => 'ro', isa => Schema, required => 1, default => sub { SQL::Translator::Object::Schema->new } ); +has 'name' => ( + is => 'ro', + isa => Str, + required => 1 +); + +has 'columns' => ( + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Column], + required => 1 +); + +has 'indexes' => ( + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Index], + required => 0 +); + +has 'constraints' => ( + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Constraint], + required => 0 +); + +has 'schema' => ( + is => 'ro', + isa => Schema, + required => 1, + default => sub { SQL::Translator::Object::Schema->new } +); 1; diff --git a/lib/SQL/Translator/Object/View.pm b/lib/SQL/Translator/Object/View.pm index 352df64..c32cf48 100644 --- a/lib/SQL/Translator/Object/View.pm +++ b/lib/SQL/Translator/Object/View.pm @@ -1,9 +1,13 @@ package SQL::Translator::Object::View; use Moose; -use MooseX::Types::Moose qw(ArrayRef); +use MooseX::Types::Moose qw(); use SQL::Translator::Types qw(); extends 'SQL::Translator::Object::Table'; -has 'sql' => (is => 'ro', isa => Str, required => 1); +has 'sql' => ( + is => 'rw', + isa => Str, + required => 1 +); 1;