[Rt-commit] [svn] r872 - in experiments/Bamboo: . lib/Bamboo lib/Bamboo/Controller lib/Bamboo/Model/ProxyObject/RT t

jesse at pallas.eruditorum.org jesse at pallas.eruditorum.org
Tue May 11 18:29:09 EDT 2004


Author: jesse
Date: Tue May 11 18:29:08 2004
New Revision: 872

Added:
   experiments/Bamboo/lib/Bamboo/Base.pm
   experiments/Bamboo/lib/Bamboo/Controller/Method.pm
   experiments/Bamboo/lib/Bamboo/Controller/MethodCollection.pm
   experiments/Bamboo/lib/Bamboo/Controller/Object.pm
   experiments/Bamboo/lib/Bamboo/Controller/ObjectCollection.pm
   experiments/Bamboo/lib/Bamboo/Controller/ParamCollection.pm
   experiments/Bamboo/t/
   experiments/Bamboo/t/0smoke.t
Modified:
   experiments/Bamboo/   (props changed)
   experiments/Bamboo/lib/Bamboo/Controller.pm
   experiments/Bamboo/lib/Bamboo/Controller/WebForms.pm
   experiments/Bamboo/lib/Bamboo/Model/ProxyObject/RT/Ticket.pm
Log:
 ----------------------------------------------------------------------
 r1521 at tinbook:  jesse | 2004-05-10T03:30:15.381419Z
 
 
 ----------------------------------------------------------------------
 r1530 at tinbook:  jesse | 2004-05-11T22:26:33.017829Z
 
 More haxxoring
 ----------------------------------------------------------------------


Added: experiments/Bamboo/lib/Bamboo/Base.pm
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/Base.pm	Tue May 11 18:29:08 2004
@@ -0,0 +1,6 @@
+package Bamboo::Base;
+use strict;
+use warnings;
+
+1;
+

Modified: experiments/Bamboo/lib/Bamboo/Controller.pm
==============================================================================
--- experiments/Bamboo/lib/Bamboo/Controller.pm	(original)
+++ experiments/Bamboo/lib/Bamboo/Controller.pm	Tue May 11 18:29:08 2004
@@ -4,25 +4,72 @@
 use warnings;
 
 use base qw/Bamboo::Base/;
+use CGI;
 
-sub validate_method_calls {
+sub new {
+    my $proto = shift;
+    my $class = ref($proto) || $proto;
+    my $self  = {};
+    bless( $self, $class );
+
+    $self->{obj_cache} = Bamboo::Controller::ObjectCache->new();
+    return $self;
+}
+
+sub parse_params_hash {
+    my $self   = shift;
+    my %params = (@_);
+    while ((my $param, my $value)  = each %params) {
+        if ( $param =~ /^(.*?)-(.*?)-(.*?)-(.*?)-(.*?)$/ ) {
+            my $object_type    = $1;
+            my $object_moniker = $2;
+            my $method         = $3;
+            my $method_moniker = $4;
+            my $param          = $5;
+
+            my $object = $self->get_object( $object_type, $object_moniker );
+            $object->add_method_param(
+                method         => $method,
+                method_moniker => $method_moniker,
+                param          => $param,
+                value          => $value
+            );
 
+        }
 
+    }
 }
 
-sub process_method_calls {
+sub get_object {
+    my $self = shift;
+    my $type = shift;
+    my $moniker = shift;
+    return $self->{'obj_cache'}->get($type, $moniker);
+}
+
+sub add_method_param {
+    my $self = shift;
+    my $object = shift;
+    my $method = shift;
+    my $param = shift;
+
+}
+
+sub validate_method_calls {
 
-figure out which objects we have to look at
-for each object
-iterate through its method calls
-for each method call
-    validate the parameters
-    if the parameters are all valid
-        make the call
-    otherwise
-        report back the parameter errors 
 
+}
 
+sub process_method_calls {
+    my $self = shift;
+    #figure out which objects we have to look at
+    foreach my $object ($self->objects_to_process()){ 
+        foreach my $method ($self->methods_for_object($object)) {
+            if ($self->validate_object_method($method,$object)){
+                $self->call_object_method($object, $method)  
+            }
+        }
+    }
 
 }
 
@@ -70,3 +117,5 @@
 
 
 }
+
+1;

Added: experiments/Bamboo/lib/Bamboo/Controller/Method.pm
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/Controller/Method.pm	Tue May 11 18:29:08 2004
@@ -0,0 +1,43 @@
+package Bamboo::Controller::Method;
+param;
+
+use strict;
+use warnings;
+
+use base qw/Bamboo::Base/;
+
+sub new  {
+  my $proto = shift;
+  my $class = ref($proto) || $proto;
+  my $self  = {};
+  bless ($self, $class);
+
+  $self->{type} = shift;
+  $self->{moniker} = shift;
+
+  $self->{'params'} = Bamboo::Controller::ParamCollection->new();
+
+  return $self;
+
+}
+
+
+sub add_param {
+    my $self = shift;
+    my $name = shift;
+    my $value = shift;
+
+    $self->{'params'}->add($name, $value);
+    
+
+
+}
+
+sub get_param {
+    my $self = shift;
+    my $param = shift;
+
+
+}
+
+1;

Added: experiments/Bamboo/lib/Bamboo/Controller/MethodCollection.pm
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/Controller/MethodCollection.pm	Tue May 11 18:29:08 2004
@@ -0,0 +1,40 @@
+package Bamboo::Controller::MethodCollection;
+
+use strict;
+use warnings;
+
+use base qw/Bamboo::Base/;
+
+sub new  {
+  my $proto = shift;
+  my $class = ref($proto) || $proto;
+  my $self  = {};
+  bless ($self, $class);
+
+  $self->method_cache({});
+
+  return $self;
+}
+
+
+sub get {
+    my $self = shift;
+    my $type = shift;
+    my $moniker = shift;
+    unless ( $self->{'method_cache'}->{$type."-".$moniker}) { 
+       $self->{'method_cache'}->{$type."-".$moniker} = Bamboo::Controller::Method->new($type, $moniker);
+       
+    }
+    return($self->{'method_cache'}->{$type."-".$moniker});
+}
+
+
+sub method_cache {
+    my $self = shift;
+
+    $self->{'method_cache'} = shift if (@_);
+    return($self->{'method_cache'});
+
+}
+
+1;

Added: experiments/Bamboo/lib/Bamboo/Controller/Object.pm
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/Controller/Object.pm	Tue May 11 18:29:08 2004
@@ -0,0 +1,38 @@
+package Bamboo::Controller::Object;
+
+use strict;
+use warnings;
+
+use base qw/Bamboo::Base/;
+
+sub new  {
+  my $proto = shift;
+  my $class = ref($proto) || $proto;
+  my $self  = {};
+  bless ($self, $class);
+
+  $self->{type} = shift;
+  $self->{moniker} = shift;
+
+  $self->{'methods'} = Bamboo::Controller::MethodCollection->new();
+
+  return $self;
+
+}
+
+
+sub add_method_param {
+    my $self = shift;
+    my %args = (
+        name         => undef,
+        moniker => undef,
+        param          => undef,
+        value          => undef,
+        @_
+    );
+    
+    my $method = $self->{'methods'}->get($args{'method'},  $args{'moniker'} );
+    $method->add_param( $args{param}, $args{value});
+}
+
+1;

Added: experiments/Bamboo/lib/Bamboo/Controller/ObjectCollection.pm
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/Controller/ObjectCollection.pm	Tue May 11 18:29:08 2004
@@ -0,0 +1,40 @@
+package Bamboo::Controller::ObjectCollection;
+
+use strict;
+use warnings;
+
+use base qw/Bamboo::Base/;
+
+sub new  {
+  my $proto = shift;
+  my $class = ref($proto) || $proto;
+  my $self  = {};
+  bless ($self, $class);
+
+  $self->object_cache({});
+
+  return $self;
+}
+
+
+sub get {
+    my $self = shift;
+    my $type = shift;
+    my $moniker = shift;
+    unless ( $self->{'object_cache'}->{$type."-".$moniker}) { 
+       $self->{'object_cache'}->{$type."-".$moniker} = Bamboo::Controller::Object->new($type, $moniker);
+       
+    }
+    return($self->{'object_cache'}->{$type."-".$moniker});
+}
+
+
+sub object_cache {
+    my $self = shift;
+
+    $self->{'object_cache'} = shift if (@_);
+    return($self->{'object_cache'});
+
+}
+
+1;

Added: experiments/Bamboo/lib/Bamboo/Controller/ParamCollection.pm
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/Controller/ParamCollection.pm	Tue May 11 18:29:08 2004
@@ -0,0 +1,62 @@
+package Bamboo::Controller::ParamCollection;
+
+use strict;
+use warnings;
+
+use base qw/Bamboo::Base/;
+
+sub new  {
+  my $proto = shift;
+  my $class = ref($proto) || $proto;
+  my $self  = {};
+  bless ($self, $class);
+
+  return $self;
+}
+
+
+sub add {
+    my $self = shift;
+    my $param = shift;
+    my $value = shift;
+
+    if ($self->{params}->{$param})  {
+        if (ref($self->{params}->{$param}) eq 'ARRAY') {
+
+            push @{$self->{params}->{$param}}, $value; 
+        }   
+        else {
+              @{$self->{params}->{$param}} = [ $self->{params}->{$param}, $value ];
+        } 
+
+    } else { 
+        $self->{params}->{$param} = $value;
+
+    }
+
+}
+
+
+sub replace {
+    my $self = shift;
+    my $param = shift;
+    my $value = shift;
+
+    $self->delete($param);
+    $self->add($param,$value); 
+
+}    
+
+sub delete {
+    my $self = shift;
+    my $param = shift;
+    delete ($self->{'params'}->{$param});
+}
+
+sub get {
+    my $self = shift;
+    my $param = shift;
+    return($self->{params}->{$param});
+}
+
+1;

Modified: experiments/Bamboo/lib/Bamboo/Controller/WebForms.pm
==============================================================================
--- experiments/Bamboo/lib/Bamboo/Controller/WebForms.pm	(original)
+++ experiments/Bamboo/lib/Bamboo/Controller/WebForms.pm	Tue May 11 18:29:08 2004
@@ -4,3 +4,6 @@
 use strict;
 
 use base qw/Bamboo::Controller/;
+
+
+1;

Modified: experiments/Bamboo/lib/Bamboo/Model/ProxyObject/RT/Ticket.pm
==============================================================================
--- experiments/Bamboo/lib/Bamboo/Model/ProxyObject/RT/Ticket.pm	(original)
+++ experiments/Bamboo/lib/Bamboo/Model/ProxyObject/RT/Ticket.pm	Tue May 11 18:29:08 2004
@@ -42,6 +42,8 @@
 
     };
 
+=for later
+
 our $RENDERERABLE = {
 
         id => { Type => 'integer', Immutable => 1 },
@@ -83,7 +85,6 @@
     }
 
 
-
         my $cfs = $Object->QueueObj->CustomFields();
         while (my $cf = $cfs->Next) {
                 $params->{$cf->Name} = { Label => $cf->Name, RenderAs => 'CollectionAsList', Object => $Object->CustomFieldValues($cf->id), Attribute => 'Content'};
@@ -91,3 +92,5 @@
         }
 
         return ($params );
+
+=cut

Added: experiments/Bamboo/t/0smoke.t
==============================================================================
--- (empty file)
+++ experiments/Bamboo/t/0smoke.t	Tue May 11 18:29:08 2004
@@ -0,0 +1,15 @@
+use Test::More qw/no_plan/;
+
+
+use_ok('Bamboo::Base');
+use_ok('Bamboo::Controller::Method');
+use_ok('Bamboo::Controller::MethodCollection');
+use_ok('Bamboo::Controller::Object');
+use_ok('Bamboo::Controller::ObjectCollection');
+use_ok('Bamboo::Controller::ParamCollection');
+use_ok('Bamboo::Controller::WebForms');
+use_ok('Bamboo::Controller');
+use_ok('Bamboo::Model::ProxyObject::RT::Queue');
+use_ok('Bamboo::Model::ProxyObject::RT::Ticket');
+use_ok('Bamboo::Model::ProxyObject');
+use_ok('Bamboo');


More information about the Rt-commit mailing list