fix extra method
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object / Index.pm
index a8df3ea..b22c041 100644 (file)
@@ -1,9 +1,7 @@
 use MooseX::Declare;
-class SQL::Translator::Object::Index {
-    use MooseX::Types::Moose qw(ArrayRef HashRef Str);
-    use MooseX::AttributeHelpers;
+class SQL::Translator::Object::Index extends SQL::Translator::Object {
+    use MooseX::Types::Moose qw(HashRef Str);
     use SQL::Translator::Types qw(Column Table);
-    extends 'SQL::Translator::Object';
 
     has 'table' => (
         is => 'rw',
@@ -17,41 +15,30 @@ class SQL::Translator::Object::Index {
         isa => Str,
         required => 1
     );
-    
+
     has 'columns' => (
-        metaclass => 'Collection::Hash',
+        traits => ['Hash'],
         is => 'rw',
         isa => HashRef[Column],
-        provides => {
-            exists => 'exists_column',
-            keys   => 'column_ids',
-            values => 'get_columns',
-            get    => 'get_column',
-            set    => 'add_column',
+        handles => {
+            exists_column => 'exists',
+            column_ids    => 'keys',
+            get_columns   => 'values',
+            get_column    => 'get',
+            add_column    => 'set',
+
+            ## compat
+            get_fields    => 'values',
+            fields        => 'keys',
         },
         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,
-        auto_deref => 1,
-    );
-
     around add_column(Column $column) { $self->$orig($column->name, $column) }
-
-    method get_fields { $self->get_columns }
-    method fields { $self->column_ids }
 }