Commit | Line | Data |
4f4fd192 |
1 | use MooseX::Declare; |
2 | class SQL::Translator::Object::Schema { |
3 | use MooseX::Types::Moose qw(HashRef Maybe Str); |
4 | use MooseX::AttributeHelpers; |
5 | use SQL::Translator::Types qw(Procedure Table View); |
6 | extends 'SQL::Translator::Object'; |
7 | |
8 | has 'name' => ( |
9 | is => 'rw', |
10 | isa => Maybe[Str], |
11 | required => 1, |
12 | default => '' |
13 | ); |
14 | |
15 | has 'tables' => ( |
16 | metaclass => 'Collection::Hash', |
17 | is => 'rw', |
18 | isa => HashRef[Table], |
19 | provides => { |
20 | exists => 'exists_table', |
21 | keys => 'table_ids', |
b5ce8643 |
22 | values => 'get_tables', |
4f4fd192 |
23 | get => 'get_table', |
24 | }, |
25 | curries => { |
26 | set => { |
27 | add_table => sub { |
28 | my ($self, $body, $table) = @_; |
29 | $self->$body($table->name, $table); |
30 | } |
44547961 |
31 | } |
4f4fd192 |
32 | }, |
b5ce8643 |
33 | default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash }, |
4f4fd192 |
34 | ); |
35 | |
36 | has 'views' => ( |
37 | metaclass => 'Collection::Hash', |
38 | is => 'rw', |
39 | isa => HashRef[View], |
40 | provides => { |
41 | exists => 'exists_view', |
42 | keys => 'view_ids', |
b5ce8643 |
43 | values => 'get_views', |
4f4fd192 |
44 | get => 'get_view', |
45 | }, |
46 | curries => { |
47 | set => { |
48 | add_view => sub { |
49 | my ($self, $body, $view) = @_; |
50 | $self->$body($view->name, $view); |
51 | } |
44547961 |
52 | } |
4f4fd192 |
53 | }, |
7c120f08 |
54 | default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash }, |
4f4fd192 |
55 | ); |
56 | |
57 | has 'procedures' => ( |
58 | metaclass => 'Collection::Hash', |
59 | is => 'rw', |
60 | isa => HashRef[Procedure], |
61 | provides => { |
62 | exists => 'exists_procedure', |
63 | keys => 'procedure_ids', |
b5ce8643 |
64 | values => 'get_procedures', |
4f4fd192 |
65 | get => 'get_procedure', |
66 | }, |
67 | curries => { |
68 | set => { |
69 | add_procedure => sub { |
70 | my ($self, $body, $procedure) = @_; |
71 | $self->$body($procedure->name, $procedure); |
72 | } |
44547961 |
73 | } |
4f4fd192 |
74 | }, |
75 | default => sub { {} }, |
76 | ); |
b5ce8643 |
77 | |
78 | method is_valid { 1 } |
4f4fd192 |
79 | } |