Commit | Line | Data |
4f4fd192 |
1 | use MooseX::Declare; |
2 | class 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' => ( |
720dcdc3 |
8 | traits => ['Array'], |
8dc32349 |
9 | is => 'rw', |
10 | isa => ArrayRef, |
720dcdc3 |
11 | handles => { |
12 | add_comment => 'push', |
13 | remove_last_comment => 'pop', |
8dc32349 |
14 | }, |
15 | default => sub { [] }, |
16 | auto_deref => 1, |
17 | ); |
18 | |
2850baeb |
19 | has '_options' => ( |
720dcdc3 |
20 | traits => ['Array'], |
2850baeb |
21 | is => 'rw', |
22 | isa => ArrayRef, |
720dcdc3 |
23 | handles => { |
24 | add_option => 'push', |
25 | remove_last_option => 'pop', |
2850baeb |
26 | }, |
27 | default => sub { [] }, |
28 | auto_deref => 1, |
29 | ); |
30 | |
6381c78d |
31 | has '_extra' => ( |
720dcdc3 |
32 | traits => ['Hash'], |
6381c78d |
33 | is => 'rw', |
34 | isa => HashRef, |
720dcdc3 |
35 | handles => { |
36 | exists_extra => 'exists', |
37 | extra_ids => 'keys', |
38 | get_extras => 'values', |
39 | get_extra => 'get', |
40 | add_extra => 'set', |
6381c78d |
41 | }, |
42 | default => sub { {} }, |
43 | auto_deref => 1, |
44 | ); |
45 | |
8dc32349 |
46 | multi method comments(Str $comment) { $self->add_comment($comment) } |
b3cafe33 |
47 | multi method comments(ArrayRef $comments) { $self->add_comment($_) for @$comments } |
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) } |
b3cafe33 |
51 | multi method options(ArrayRef $options) { $self->add_option($_) for @$options } |
0acbba1d |
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 | } |