| 1 | package SQL::Engine::Builder::ConstraintDrop; | ||
| 2 | |||
| 3 | use 5.014; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | |||
| 8 | use registry; | ||
| 9 | use routines; | ||
| 10 | |||
| 11 | use Data::Object::Class; | ||
| 12 | use Data::Object::ClassHas; | ||
| 13 | |||
| 14 | extends 'SQL::Engine::Builder'; | ||
| 15 | |||
| 16 | use SQL::Validator; | ||
| 17 | |||
| 18 | our $VERSION = '0.02'; # VERSION | ||
| 19 | |||
| 20 | # ATTRIBUTES | ||
| 21 | |||
| 22 | has name => ( | ||
| 23 | is => 'ro', | ||
| 24 | isa => 'Str', | ||
| 25 | opt => 1 | ||
| 26 | ); | ||
| 27 | |||
| 28 | has source => ( | ||
| 29 | is => 'ro', | ||
| 30 | isa => 'HashRef', | ||
| 31 | req => 1 | ||
| 32 | ); | ||
| 33 | |||
| 34 | has target => ( | ||
| 35 | is => 'ro', | ||
| 36 | isa => 'HashRef', | ||
| 37 | opt => 1 | ||
| 38 | ); | ||
| 39 | |||
| 40 | has safe => ( | ||
| 41 | is => 'ro', | ||
| 42 | isa => 'Bool', | ||
| 43 | opt => 1 | ||
| 44 | ); | ||
| 45 | |||
| 46 | # METHODS | ||
| 47 | |||
| 48 | method data() { | ||
| 49 | my $schema = {}; | ||
| 50 | |||
| 51 | if ($self->name) { | ||
| 52 | $schema->{"name"} = $self->name; | ||
| 53 | } | ||
| 54 | |||
| 55 | if ($self->source) { | ||
| 56 | $schema->{"source"} = $self->source; | ||
| 57 | } | ||
| 58 | |||
| 59 | if ($self->target) { | ||
| 60 | $schema->{"target"} = $self->target; | ||
| 61 | } | ||
| 62 | |||
| 63 | if ($self->safe) { | ||
| 64 | $schema->{"safe"} = $self->safe; | ||
| 65 | } | ||
| 66 | |||
| 67 | return { | ||
| 68 | "constraint-drop" => $schema | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | 1; |