1 package SQL::Translator::Schema::Role::Extra;
7 The following methods are defined here, therefore all schema objects
8 using this role will have them.
12 Get or set the objects "extra" attibutes (e.g., "ZEROFILL" for MySQL fields).
13 Call with no args to get all the extra data.
14 Call with a single name arg to get the value of the named extra attribute,
15 returned as a scalar. Call with a hash or hashref to set extra attributes.
16 Returns a hash or a hashref.
18 $field->extra( qualifier => 'ZEROFILL' );
20 $qualifier = $field->extra('qualifier');
22 %extra = $field->extra;
23 $extra = $field->extra;
27 has extra => ( is => 'rwp', default => sub { +{} } );
30 my ($orig, $self) = (shift, shift);
32 @_ = %{$_[0]} if ref $_[0] eq "HASH";
33 my $extra = $self->$orig;
36 return exists($extra->{$_[0]}) ? $extra->{$_[0]} : undef ;
40 while ( my ( $key, $value ) = each %args ) {
41 $extra->{$key} = $value;
45 return wantarray ? %$extra : $extra;
50 L</extra> can only be used to get or set "extra" attributes but not to
51 remove some. Call with no args to remove all extra attributes that
52 have been set before. Call with a list of key names to remove
53 certain extra attributes only.
55 # remove all extra attributes
56 $field->remove_extra();
58 # remove timezone and locale attributes only
59 $field->remove_extra(qw/timezone locale/);
64 my ( $self, @keys ) = @_;
66 $self->_set_extra({});
69 delete @{$self->extra}{@keys};