File Coverage

blib/lib/Language/LispPerl/Var.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 23 25 92.0


line stmt bran cond sub pod time code
1             package Language::LispPerl::Var;
2             $Language::LispPerl::Var::VERSION = '0.005';
3 6     6   38 use Moose;
  6         12  
  6         85  
4 6     6   45637 use Moose::Util::TypeConstraints;
  6         14  
  6         65  
5              
6 6     6   11346 use Language::LispPerl::Printer;
  6         14  
  6         178  
7 6     6   33 use Language::LispPerl::Reader;
  6         11  
  6         1407  
8              
9             has 'name' => ( is => 'ro', isa => 'Str', required => 1 );
10             has 'value' => ( is => 'rw' , isa => union(['Undef',
11             'Str',
12             class_type( 'Language::LispPerl::Atom'),
13             class_type('Language::LispPerl::Seq') ] ) );
14              
15             sub to_hash{
16 10     10 0 12 my ($self) = @_;
17             return {
18 10         251 name => $self->name(),
19             value => Language::LispPerl::Printer::to_perl( $self->value() ),
20             __class => $self->blessed(),
21             };
22             }
23              
24             sub from_hash{
25 5     5 0 7 my ($class, $hash) = @_;
26             return $class->new({
27 5         11 map{ $_ => Language::LispPerl::Reader::from_perl( $hash->{$_} ) } keys %$hash
  15         33  
28             });
29             }
30              
31             __PACKAGE__->meta()->make_immutable();
32             1;
33              
34             =head1 NAME
35              
36             Language::LispPerl::Var - A variable with a name (ro) and a value (rw)
37              
38             =cut