File: FactSubclasses.pm

package info (click to toggle)
libmetabase-fact-perl 0.025-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 1,076; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 957 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package FactSubClasses;
use strict;
use warnings;

use Metabase::Fact::String;
use Metabase::Fact::Hash;

package FactOne;
our @ISA = ('Metabase::Fact::String');
sub content_as_bytes   { return reverse( $_[0]->{content} ) }
sub content_from_bytes { return reverse( $_[1] ) }

package FactTwo;
our @ISA = ('Metabase::Fact::String');
sub content_as_bytes   { return reverse( $_[0]->{content} ) }
sub content_from_bytes { return reverse( $_[1] ) }

package FactThree;
our @ISA = ('Metabase::Fact::String');

sub validate_content {
    $_[0]->SUPER::validate_content;
    die "content not positive length" unless length $_[0]->content > 0;
}

sub content_metadata {
    return { 'length' => [ '//num' => length $_[0]->content ] };
}

package FactFour;
our @ISA = ('Metabase::Fact::Hash');
sub required_keys { qw/ first / }
sub optional_keys { qw/ second / }

sub content_metadata {
    return { 'size' => [ '//num' => scalar keys %{ $_[0]->content } ] };
}

1;