File: Coercions.pm

package info (click to toggle)
libspecio-perl 0.50-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 900 kB
  • sloc: perl: 5,165; sh: 23; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 397 bytes parent folder | download | duplicates (5)
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
package Specio::Library::Coercions;

use strict;
use warnings;

use parent 'Specio::Exporter';

use Specio::Declare;
use Specio::Library::Builtins;

declare(
    'IntC',
    parent => t('Int'),
);

coerce(
    t('IntC'),
    from  => t('ArrayRef'),
    using => sub { scalar @{ $_[0] } },
);

coerce(
    t('IntC'),
    from   => t('HashRef'),
    inline => sub {"scalar keys %{ $_[1] }"},
);

1;