| 1 | package Language::LispPerl::Var; | ||
| 2 | 6 | $Language::LispPerl::Var::VERSION = '0.007'; | |
| 3 | 6 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 6 | ▶ | use Moose::Util::TypeConstraints; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 6 | ▶ | use Language::LispPerl::Printer; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 6 | ▶ | use Language::LispPerl::Reader; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 6 | has 'name' => ( is => 'ro', isa => 'Str', required => 1 ); | |
| 10 | 6 | has 'value' => ( is => 'rw' , isa => union(['Undef', | |
| 11 | 'Str', | ||
| 12 | class_type( 'Language::LispPerl::Atom'), | ||
| 13 | class_type('Language::LispPerl::Seq') ] ) ); | ||
| 14 | |||
| 15 | 12 | ▶ | sub to_hash{ |
|
Subroutine
to_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 16 | 12 | my ($self) = @_; | |
| 17 | return { | ||
| 18 | 12 | name => $self->name(), | |
| 19 | value => Language::LispPerl::Printer::to_perl( $self->value() ), | ||
| 20 | __class => $self->blessed(), | ||
| 21 | }; | ||
| 22 | } | ||
| 23 | |||
| 24 | 6 | ▶ | sub from_hash{ |
|
Subroutine
from_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 25 | 6 | my ($class, $hash) = @_; | |
| 26 | return $class->new({ | ||
| 27 | 6 | map{ $_ => Language::LispPerl::Reader::from_perl( $hash->{$_} ) } keys %$hash | |
| 28 | }); | ||
| 29 | } | ||
| 30 | |||
| 31 | 6 | __PACKAGE__->meta()->make_immutable(); | |
| 32 | 6 | 1; | |
| 33 | |||
| 34 | =head1 NAME | ||
| 35 | |||
| 36 | Language::LispPerl::Var - A variable with a name (ro) and a value (rw) | ||
| 37 | |||
| 38 | =cut | ||