[Catalyst-commits] r7181 - in Catalyst-Model-SOAP/1.0/trunk: . lib/Catalyst/Model t

ruoso at dev.catalyst.perl.org ruoso at dev.catalyst.perl.org
Wed Nov 28 15:55:46 GMT 2007


Author: ruoso
Date: 2007-11-28 15:55:46 +0000 (Wed, 28 Nov 2007)
New Revision: 7181

Modified:
   Catalyst-Model-SOAP/1.0/trunk/Makefile.PL
   Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm
   Catalyst-Model-SOAP/1.0/trunk/t/01_basics.t
Log:
[C-M-SOAP] This is what seems to be the first version



Modified: Catalyst-Model-SOAP/1.0/trunk/Makefile.PL
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/Makefile.PL	2007-11-28 15:33:30 UTC (rev 7180)
+++ Catalyst-Model-SOAP/1.0/trunk/Makefile.PL	2007-11-28 15:55:46 UTC (rev 7181)
@@ -5,6 +5,6 @@
    NAME              => 'Catalyst::Model::SOAP',
    VERSION_FROM      => 'lib/Catalyst/Model/SOAP.pm',
    PREREQ_PM         => { Catalyst::Runtime => 5.7011, XML::Compile::SOAP => 0 },
-   ABSTRACT_FROM  => 'lib/Catalyst/Model/SOAP.pm', # retrieve abstract from module
+   ABSTRACT_FROM  => 'lib/Catalyst/Model/SOAP.pm',
    AUTHOR         => 'Daniel Ruoso <daniel.ruoso at verticalone.pt>',
   );

Modified: Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm	2007-11-28 15:33:30 UTC (rev 7180)
+++ Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm	2007-11-28 15:55:46 UTC (rev 7181)
@@ -2,18 +2,16 @@
     use strict;
     use warnings;
     use XML::Compile::SOAP;
-    use base qw(Catalyst::Model Class::Data::Accessor);
+    use base qw(Catalyst::Model);
     our $VERSION = '0.0.1';
-
-    __PACKAGE__->mk_classaccessor('wsdl_classes' => {});
-
     sub register_wsdl {
         my ($self, $wsdl, $target) = @_;
 
-        no strict 'refs';
         my $wsdl_obj = XML::Compile::SOAP::WSDL11->new($wsdl);
         my $realtarget = $self.'::'.$target;
 
+        no strict 'refs';
+        @{$realtarget.'::ISA'} = qw(Catalyst::Model::SOAP::Instance);
         foreach my $operation ($wsdl_obj->operations(produce => 'OBJECTS')) {
             my $code = $operation->compileClient();
             *{$realtarget.'::'.$operation->name()} = sub {
@@ -24,11 +22,13 @@
                 return ($wsdl_obj, $operation, $code);
             };
         }
-
-        $self->wsdl_classes->{$realtarget} = 1;
-
     }
 };
+{   package Catalyst::Model::SOAP::Instance;
+    use strict;
+    use warnings;
+    use base qw(Catalyst::Model);
+}
 1;
 
 __END__
@@ -42,8 +42,8 @@
   {# In the model class...
       package MyApp::Model::SOAP;
       use base qw(Catalyst::Model::SOAP);
-      __PACKAGE__->register_wsdl('http://foo.bar/baz.wsdl', 'SOAP::Baz');
-      __PACKAGE__->register_wsdl('http://baz.bar/foo.wsdl', 'SOAP::Foo');
+      __PACKAGE__->register_wsdl('http://foo.bar/baz.wsdl', 'Baz');
+      __PACKAGE__->register_wsdl('http://baz.bar/foo.wsdl', 'Foo');
   };
   {# later in some other class..
      $c->model('SOAP::Baz')->getWeather(%arguments);
@@ -73,7 +73,7 @@
 
 This method will register the operations described by $wsdl in the
 $targetclass package. $wsdl may be anythin XML::Compile::SOAP::WSDL11
-accepts, the $targetclass is a relative package name which will be
+accepts. The $targetclass is a relative package name which will be
 concatenated in the name of the model.
 
 Note that XML::Compile->knownNamespace(...) can be used to help

Modified: Catalyst-Model-SOAP/1.0/trunk/t/01_basics.t
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/t/01_basics.t	2007-11-28 15:33:30 UTC (rev 7180)
+++ Catalyst-Model-SOAP/1.0/trunk/t/01_basics.t	2007-11-28 15:55:46 UTC (rev 7181)
@@ -1,5 +1,5 @@
 
-use Test::More tests => 7;
+use Test::More tests => 9;
 use Symbol;
 BEGIN { use_ok('Catalyst::Model::SOAP') };
 
@@ -12,8 +12,17 @@
     __PACKAGE__->register_wsdl('http://foo.bar/baz.wsdl', 'Bar::Baz');
 };
 
-ok(defined *{::MyFooModel::Bar::Baz::op1}, 'Loading the wsdl pre-registers the method.');
-ok(defined *{::MyFooModel::Bar::Baz::_op1_data}, 'Loading the wsdl pre-register the helper-method');
+{
+    package Catalyst::Model::SOAP::Instance;
+    sub foo {
+        return 'ok';
+    }
+};
+
+ok(defined @MyFooModel::Bar::Baz::ISA, 'Loading the wsdl pre-registers the class.');
+is(MyFooModel::Bar::Baz->foo(), 'ok', 'The dynamic class isa Catalyst::Model::SOAP::Instance.');
+ok(defined &MyFooModel::Bar::Baz::op1, 'Loading the wsdl pre-registers the method.');
+ok(defined &MyFooModel::Bar::Baz::_op1_data, 'Loading the wsdl pre-register the helper-method');
 is(MyFooModel::Bar::Baz->op1, 'op1', 'The method calls the coderef.');
 my @data = MyFooModel::Bar::Baz->_op1_data();
 is(ref $data[0], 'MyXML::WSDL11', 'The first element in the data is the wsdl object');




More information about the Catalyst-commits mailing list