1package Oryx::Value::String; 2use base qw(Oryx::Value); 3 4use Data::Types qw(is_string to_string); 5 6sub primitive { 'String' } 7 8sub check_size { 9 my ($self, $value) = @_; 10 if (defined $self->meta->size) { 11 return length($value) <= $self->meta->size; 12 } 13 return 1; 14} 15 16sub check_type { 17 my ($self, $value) = @_; 18 return is_string($value); 19} 20 21sub inflate { 22 my ($self, $value) = @_; 23 return to_string($value); 24} 25 26sub deflate { 27 my ($self, $value) = @_; 28 return to_string($value); 29} 30 311; 32__END__ 33 34=head1 NAME 35 36Oryx::Value::String - Values containing short strings 37 38=head1 SYNOPSIS 39 40 package CMS::Person; 41 42 use base qw( Oryx::Class ); 43 44 our $schema = { 45 attributes => [ { 46 name => 'full_name', 47 type => 'String', 48 }, { 49 name => 'email_address', 50 type => 'String', 51 } ], 52 }; 53 54 $x = CMS::Person->create({ 55 full_name => 'Richard Hundt', 56 email_address => 'richard NO SPAM AT protea-systems.com', 57 }); 58 59=head1 DESCRIPTION 60 61This value type stores relatively short strings. Most databases will allow strings to be stored in these fields up to 255 characters in length. There is an optional "size" metadata attribute for this type which can set this to an arbitrary value (defaults to 255). 62 63The value is stored as a "String" primitive type. 64 65=head1 SEE ALSO 66 67L<Oryx::Value> 68 69=head1 AUTHOR 70 71Richard Hundt E<lt>richard NO SPAM AT protea-systems.comE<gt> 72 73=head1 COPYRIGHT AND LICENSE 74 75This library is free software and may be used under the same terms as Perl itself. 76 77=cut 78