Oryx::Value::Integer - Values containing integers


Oryx documentation Contained in the Oryx distribution.

Index


Code Index:

NAME

Top

Oryx::Value::Integer - Values containing integers

SYNOPSIS

Top

  package CMS::Counter;

  use base qw( Oryx::Class );

  our $schema = {
      attributes => [ {
          name => 'url',
          type => 'String',
      }, {
          name => 'hit_count',
          type => 'Integer',
      } ],
  };

  $x = CMS::Picture->create({
      url       => 'http://example.com/',
      hit_count => 12_542,
  });

DESCRIPTION

Top

A field with this value type will store integers.

The value will be checked that it is an integer and is stored in an "Integer" primitive type.

SEE ALSO

Top

Oryx::Value

AUTHOR

Top

Richard Hundt <richard NO SPAM AT protea-systems.com>

COPYRIGHT AND LICENSE

Top


Oryx documentation Contained in the Oryx distribution.

package Oryx::Value::Integer;
use base qw(Oryx::Value);

use Data::Types qw(is_int to_int);

sub primitive { 'Integer' }

sub check_type {
    my ($self, $value) = @_;
    return is_int($value);
}

sub check_size {
    my ($self, $value) = @_;
    if (defined $self->meta->size) {
	return $value <= $self->meta->size;
    }
    return 1;
}

sub inflate {
    my ($self, $value) = @_;
    return to_int($value);
}

sub deflate {
    my ($self, $value) = @_;
    return to_int($value);
}

1;
__END__