fix options and comments methods
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object.pm
index af3ad53..b593f02 100644 (file)
@@ -2,7 +2,7 @@ use MooseX::Declare;
 class SQL::Translator::Object {
     use Tie::IxHash;
     use MooseX::MultiMethods;
-    use MooseX::Types::Moose qw(Any ArrayRef Str);
+    use MooseX::Types::Moose qw(Any ArrayRef HashRef Str);
 
     has '_comments' => (
         metaclass => 'Collection::Array',
@@ -28,11 +28,30 @@ class SQL::Translator::Object {
         auto_deref => 1,
     );
 
+    has '_extra' => (
+        metaclass => 'Collection::Hash',
+        is => 'rw',
+        isa => HashRef,
+        provides => {
+            exists => 'exists_extra',
+            keys   => 'extra_ids',
+            values => 'get_extras',
+            get    => 'get_extra',
+            set    => 'add_extra',
+        },
+        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 comments(ArrayRef $comments) { $self->add_comment($_) for @$comments }
+    multi method comments(Any $) { 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) if scalar @$option }
+    multi method options(ArrayRef $options) { $self->add_option($_) for @$options }
     multi method options(Any $) { wantarray ? @{$self->_options} : $self->_options }
+
+    multi method extra(Str $extra) { $self->get_extra($extra) }
+    multi method extra(HashRef $extra) { $self->_extra($extra) }
+    multi method extra(Any $) { wantarray ? %{$self->_extra} : $self->_extra }
 }