[Bps-public-commit] net-lighthouse branch, master, updated. 48b2ebe56afa48237077dee17816f060b8bd0683

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Aug 31 01:30:06 EDT 2009


The branch, master has been updated
       via  48b2ebe56afa48237077dee17816f060b8bd0683 (commit)
      from  0242ca0f4e2164ce5966d37091bd66e5fa515691 (commit)

Summary of changes:
 lib/Net/Lighthouse/Util.pm |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 48b2ebe56afa48237077dee17816f060b8bd0683
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Aug 31 13:29:33 2009 +0800

    handle boolean and datetime types in xml

diff --git a/lib/Net/Lighthouse/Util.pm b/lib/Net/Lighthouse/Util.pm
index 63c8a4a..66396f7 100644
--- a/lib/Net/Lighthouse/Util.pm
+++ b/lib/Net/Lighthouse/Util.pm
@@ -6,7 +6,7 @@ use XML::Simple;
 use DateTime;
 
 sub translate_from_xml {
-    my $self = shift;
+    my $class = shift;
     my $ref = shift;
     $ref = XMLin( $ref, KeyAttr => [] ) unless ref $ref;
     %$ref = map { my $new = $_; $new =~ s/-/_/g; $new => $ref->{$_} } keys %$ref;
@@ -15,6 +15,18 @@ sub translate_from_xml {
             if ( $ref->{$k}{nil} && $ref->{$k}{nil} eq 'true' ) {
                 $ref->{$k} = undef;
             }
+            elsif ( $ref->{$k}{type} && $ref->{$k}{type} eq 'boolean' ) {
+                if ( $ref->{$k}{content} eq 'true' ) {
+                    $ref->{$k} = 1;
+                }
+                else {
+                    $ref->{$k} = 0;
+                }
+            }
+            elsif ( $ref->{$k}{type} && $ref->{$k}{type} eq 'datetime' ) {
+                    $ref->{$k} =
+                      $class->datetime_from_string( $ref->{$k}{content} );
+            }
             elsif ( defined $ref->{$k}{content} ) {
                 $ref->{$k} = $ref->{$k}{content};
             }

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



More information about the Bps-public-commit mailing list