include Moo version in a single place
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Schema / Field.pm
index 25e8074..d8680cb 100644 (file)
@@ -25,7 +25,8 @@ C<SQL::Translator::Schema::Field> is the field object.
 use Moo;
 use SQL::Translator::Schema::Constants;
 use SQL::Translator::Types qw(schema_obj);
-use SQL::Translator::Utils qw(parse_list_arg ex2err throw);
+use SQL::Translator::Utils qw(parse_list_arg ex2err throw carp_ro);
+use Sub::Quote qw(quote_sub);
 
 extends 'SQL::Translator::Schema::Object';
 
@@ -97,8 +98,8 @@ all the comments joined on newlines.
 
 has comments => (
     is => 'rw',
-    coerce => sub { ref($_[0]) eq 'ARRAY' ? $_[0] : [$_[0]] },
-    default => sub { [] },
+    coerce => quote_sub(q{ ref($_[0]) eq 'ARRAY' ? $_[0] : [$_[0]] }),
+    default => quote_sub(q{ [] }),
 );
 
 around comments => sub {
@@ -124,7 +125,7 @@ Get or set the field's data type.
 
 =cut
 
-has data_type => ( is => 'rw', default => sub { '' } );
+has data_type => ( is => 'rw', default => quote_sub(q{ '' }) );
 
 =head2 sql_data_type
 
@@ -200,7 +201,7 @@ Get or set the field's C<is_auto_increment> attribute.
 
 has is_auto_increment => (
     is => 'rw',
-    coerce => sub { $_[0] ? 1 : 0 },
+    coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
     builder => 1,
     lazy => 1,
 );
@@ -231,7 +232,7 @@ Returns whether or not the field is a foreign key.
 
 has is_foreign_key => (
     is => 'rw',
-    coerce => sub { $_[0] ? 1 : 0 },
+    coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
     builder => 1,
     lazy => 1,
 );
@@ -272,8 +273,8 @@ foreign keys; checks) are represented as table constraints.
 
 has is_nullable => (
     is => 'rw',
-    coerce => sub { $_[0] ? 1 : 0 },
-    default => sub { 1 },
+    coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
+    default => quote_sub(q{ 1 }),
  );
 
 around is_nullable => sub {
@@ -293,7 +294,7 @@ a table constraint (should it?).
 
 has is_primary_key => (
     is => 'rw',
-    coerce => sub { $_[0] ? 1 : 0 },
+    coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
     lazy => 1,
     builder => 1,
 );
@@ -320,6 +321,8 @@ Determine whether the field has a UNIQUE constraint or not.
 
 has is_unique => ( is => 'lazy', init_arg => undef );
 
+around is_unique => carp_ro('is_unique');
+
 sub _build_is_unique {
     my ( $self ) = @_;
 
@@ -406,7 +409,7 @@ Get or set the field's order.
 
 =cut
 
-has order => ( is => 'rw', default => sub { 0 } );
+has order => ( is => 'rw', default => quote_sub(q{ 0 }) );
 
 around order => sub {
     my ( $orig, $self, $arg ) = @_;
@@ -451,7 +454,7 @@ numbers and returns a string.
 
 has size => (
     is => 'rw',
-    default => sub { [0] },
+    default => quote_sub(q{ [0] }),
     coerce => sub {
         my @sizes = grep { defined && m/^\d+(?:\.\d+)?$/ } @{parse_list_arg($_[0])};
         @sizes ? \@sizes : [0];