[Bps-public-commit] lcore branch, master, updated. 04f4dc828157d1cd66763035702fadd364df0fab

clkao at bestpractical.com clkao at bestpractical.com
Fri Oct 9 08:47:05 EDT 2009


The branch, master has been updated
       via  04f4dc828157d1cd66763035702fadd364df0fab (commit)
       via  5ce198ad52bf7ac960c8387187e205b9cf1c5a02 (commit)
      from  3cce490baac91e5b18eb04407c7a6d5599076ca5 (commit)

Summary of changes:
 lib/LCore/Expression/Application.pm |    7 ++++++-
 lib/LCore/Parameter.pm              |    4 ++++
 2 files changed, 10 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 5ce198ad52bf7ac960c8387187e205b9cf1c5a02
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Fri Oct 9 20:46:26 2009 +0800

    serialize name-based application.

diff --git a/lib/LCore/Expression/Application.pm b/lib/LCore/Expression/Application.pm
index 5211967..b2aaae6 100644
--- a/lib/LCore/Expression/Application.pm
+++ b/lib/LCore/Expression/Application.pm
@@ -10,9 +10,14 @@ has operands => (is => "ro", isa => "HashRef|ArrayRef[LCore::Expression|CodeRef]
 
 sub to_hash {
     my ($self) = shift;
+    my $operands = $self->operands;
+
     return { type => 'application',
              operator => $self->operator->to_hash,
-             operands => [ map { $_->to_hash } @{$self->operands } ],
+             operands =>
+                 ref($operands) eq 'HASH'
+                     ? { map { $_ => $operands->{$_}->to_hash } keys %$operands}
+                     : [ map { $_->to_hash } @{$self->operands } ],
          };
 }
 

commit 04f4dc828157d1cd66763035702fadd364df0fab
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Fri Oct 9 20:46:55 2009 +0800

    provide to_hash for LCore::Parameter

diff --git a/lib/LCore/Parameter.pm b/lib/LCore/Parameter.pm
index b7ba5aa..52fb583 100644
--- a/lib/LCore/Parameter.pm
+++ b/lib/LCore/Parameter.pm
@@ -9,6 +9,10 @@ use overload (
     '""' => sub { my $self = shift; $self->name },
 );
 
+sub to_hash {
+    my ($self) = shift;
+    return { name => $self->name, type => $self->type };
+}
 
 __PACKAGE__->meta->make_immutable;
 no Moose;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list