From: Justin Hunter Date: Sun, 23 Aug 2009 06:58:39 +0000 (-0700) Subject: move options down to Object.pm X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2850baeb2e26f3b7df5b285f9472dbf935d5b101;p=dbsrgits%2FSQL-Translator-2.0-ish.git move options down to Object.pm --- diff --git a/lib/SQL/Translator/Object.pm b/lib/SQL/Translator/Object.pm index 271e1da..cc6f5aa 100644 --- a/lib/SQL/Translator/Object.pm +++ b/lib/SQL/Translator/Object.pm @@ -16,7 +16,23 @@ class SQL::Translator::Object { auto_deref => 1, ); + has '_options' => ( + metaclass => 'Collection::Array', + is => 'rw', + isa => ArrayRef, + provides => { + push => 'add_option', + pop => 'remove_last_option', + }, + default => sub { [] }, + auto_deref => 1, + ); + multi method comments(Str $comment) { $self->add_comment($comment) } multi method comments(ArrayRef $comment) { $self->add_comment($comment) } multi method comments(Any $) { return wantarray ? @{$self->_comments} : join "\n", $self->_comments } + + multi method options(Str $option) { $self->add_option($option) } + multi method options(ArrayRef $option) { $self->add_option($option) } + multi method options(Any $) { $self->_options } } diff --git a/lib/SQL/Translator/Object/Constraint.pm b/lib/SQL/Translator/Object/Constraint.pm index 3f46a30..1a933ea 100644 --- a/lib/SQL/Translator/Object/Constraint.pm +++ b/lib/SQL/Translator/Object/Constraint.pm @@ -60,12 +60,6 @@ class SQL::Translator::Object::Constraint { auto_deref => 1 ); - has 'options' => ( - is => 'rw', - isa => ArrayRef, - auto_deref => 1 - ); - has 'extra' => ( is => 'rw', isa => HashRef, diff --git a/lib/SQL/Translator/Object/Index.pm b/lib/SQL/Translator/Object/Index.pm index a8df3ea..ced7635 100644 --- a/lib/SQL/Translator/Object/Index.pm +++ b/lib/SQL/Translator/Object/Index.pm @@ -17,7 +17,7 @@ class SQL::Translator::Object::Index { isa => Str, required => 1 ); - + has 'columns' => ( metaclass => 'Collection::Hash', is => 'rw', @@ -31,19 +31,13 @@ class SQL::Translator::Object::Index { }, default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash }, ); - + has 'type' => ( is => 'rw', isa => Str, required => 1 ); - has 'options' => ( - is => 'rw', - isa => ArrayRef, - auto_deref => 1 - ); - has 'extra' => ( is => 'rw', isa => HashRef, diff --git a/lib/SQL/Translator/Object/Table.pm b/lib/SQL/Translator/Object/Table.pm index ba97281..4e75ad5 100644 --- a/lib/SQL/Translator/Object/Table.pm +++ b/lib/SQL/Translator/Object/Table.pm @@ -69,16 +69,17 @@ class SQL::Translator::Object::Table { default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash }, ); - has 'temporary' => ( + has 'schema' => ( is => 'rw', - isa => Bool, - default => 0 + isa => Schema, + weak_ref => 1, + required => 1, ); - has 'options' => ( + has 'temporary' => ( is => 'rw', - isa => ArrayRef, - auto_deref => 1 + isa => Bool, + default => 0 ); has 'extra' => (