No Merit Moose

Well today in the Moose-pen I do not have very much moose to look at as I am getting close to finishing off the Accessor.pm at least code wise, hey I even started to write up the POD for it so the end game is near.

So for today cleanup I noticed that in an earlier post I planed this

00~09 basic sanity tests
10~19 Database::Accessor Classes sanity test
20~29 DAD load tests
30~39 Accessor.pm static tests
40~49 Accessor.pm dynamic tests
50~69 Integration.

was my general plan for testing Accessor.pm.

Seems I did both the static and dynamic tests in the same 30~39 range should. Well that is nothing much just a bunch of code movement out of the 30 range and into the 40 so I am not going to bore you with that here.

Now for the Integration testing I had to update my Acessor.pm to fully reflect my API so I re-factored the code in retrieve a into its own sub and the added the remaining three of my four my CRUD subs again not moose or rocket science there.

Well I did want to do a little Moose today so I give something called MooseX-AttributeCloner. The idea being I could get rid of this


my $dad = $driver->new(
{
View => $self->view,
Elements => $self->elements,
elements => $self->dynamic_elements,
Conditions => $self->conditions,
conditions => $self->dynamic_conditions,
Links => $self->links,
links => $self->dynamic_links,
Gathers => $self->gathers,
gathers => $self->dynamic_gathers,
Filters => $self->filters,
filters => $self->dynamic_filters,
Sorts => $self->sorts,
sorts => $self->dynamic_sorts,
}
);

with something simple like this

my $dad = $self->new_with_cloned_attributes($driver);

So to get this to work I had to add in to my Accessor.pm with command

use Moose;
with qw(Database::Accessor::Types
MooseX::AttributeCloner);

then make the swap for the above and then I had to change the Attributes on my Database::Accessor::Roles::DAD and my Database::Accessor class all matched up. So no more Elements and elements on my DADs it was now elements and dynamic_elements. I also had to make some changes to what I was expecting from my $da->Execute(). In 'Database::Accessor::DAD::Test' instead of simply returning $self I put the $self, the DAD, onto the container hash-ref that should be a param on the Execute function;

sub Execute {
my $self = shift;
my($type, $conn, $container, $opt) = @_;
– return $self;
++ $container->{dad} = $self;
}

so in my test, 39_sorts.t was the one I was playing with I changed it a little like this

my $return_str = {};
$da->retrieve(Data::Test->new(),$return_str);
my $dad = $return_str->{dad};
Test::Database::Accessor::Utils::deep_element($in_hash->{sorts},$da->sorts,$dad->sorts,'Sorts');

Now that test above passed it was when I was getting into the dynamic_sort that things came apart Played with this for a good two or three hours and sort of debugging MooseX::AttributeCloner, (I will save that for a later post) I just cut my losses and went back to what I had in the first place.

I was not a total loss, having a look at the the changes I made in 'Database::Accessor::Roles::DAD' I decided to stick with the the name changes as elements and dynamic_elements are a little easier to understand than Elements and elements best to keep the names the same.

As well I am glad I finally beginning to tighten up my DAD call. I always wanted my DAD to effect only the passed in $container and this change makes me do that.

Well a little good done today but no merit badge for Moose as I have to go back and clean up all my tests to account for the new changes. Thank-fully I have not got to that point in my POD writing.

s-l1000.jpg


Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations