move comments down to the base Object
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object.pm
1 use MooseX::Declare;
2 class SQL::Translator::Object {
3     use Tie::IxHash;
4     use MooseX::MultiMethods;
5     use MooseX::Types::Moose qw(Any ArrayRef Str);
6
7     has '_comments' => (
8         metaclass => 'Collection::Array',
9         is => 'rw',
10         isa => ArrayRef,
11         provides => {
12             push => 'add_comment',
13             pop  => 'remove_last_comment',
14         },
15         default => sub { [] },
16         auto_deref => 1,
17     );
18
19     multi method comments(Str $comment) { $self->add_comment($comment) }
20     multi method comments(ArrayRef $comment) { $self->add_comment($comment) }
21     multi method comments(Any $) { return wantarray ? @{$self->_comments} : join "\n", $self->_comments }
22 }