move extra down to Object.pm
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object.pm
CommitLineData
4f4fd192 1use MooseX::Declare;
2class SQL::Translator::Object {
3 use Tie::IxHash;
8dc32349 4 use MooseX::MultiMethods;
6381c78d 5 use MooseX::Types::Moose qw(Any ArrayRef HashRef Str);
8dc32349 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
2850baeb 19 has '_options' => (
20 metaclass => 'Collection::Array',
21 is => 'rw',
22 isa => ArrayRef,
23 provides => {
24 push => 'add_option',
25 pop => 'remove_last_option',
26 },
27 default => sub { [] },
28 auto_deref => 1,
29 );
30
6381c78d 31 has '_extra' => (
32 metaclass => 'Collection::Hash',
33 is => 'rw',
34 isa => HashRef,
35 provides => {
36 exists => 'exists_extra',
37 keys => 'extra_ids',
38 values => 'get_extras',
39 get => 'get_extra',
40 set => 'add_extra',
41 },
42 default => sub { {} },
43 auto_deref => 1,
44 );
45
8dc32349 46 multi method comments(Str $comment) { $self->add_comment($comment) }
47 multi method comments(ArrayRef $comment) { $self->add_comment($comment) }
6381c78d 48 multi method comments(Any $) { wantarray ? @{$self->_comments} : join "\n", $self->_comments }
2850baeb 49
50 multi method options(Str $option) { $self->add_option($option) }
0acbba1d 51 multi method options(ArrayRef $option) { $self->add_option($option) if scalar @$option }
52 multi method options(Any $) { wantarray ? @{$self->_options} : $self->_options }
6381c78d 53
54 multi method extra(Str $extra) { $self->get_extra($extra) }
55 multi method extra(HashRef $extra) { $self->_extra($extra) }
56 multi method extra(Any $) { wantarray ? %{$self->_extra} : $self->_extra }
4f4fd192 57}