Metabase-Fact

 view release on metacpan or  search on metacpan

lib/Metabase/Fact/String.pm  view on Meta::CPAN


sub validate_content {
    my ($self) = @_;
    Carp::confess "content must be scalar value"
      unless defined $self->content && ref \( $self->content ) eq 'SCALAR';
}

sub content_as_bytes {
    my ($self) = @_;
    my $bytes = $self->content;
    utf8::encode($bytes) if $] ge '5.008'; # converts in-place
    return $bytes;
}

sub content_from_bytes {
    my ( $class, $bytes ) = @_;
    utf8::decode($bytes) if $] ge '5.008'; # converts in-place
    return $bytes;
}

1;

# ABSTRACT: fact subtype for simple strings

__END__

=pod



( run in 0.267 second using v1.01-cache-2.11-cpan-fb7fbe3ddfd )