I think we really need an example which we can run that demonstrates the problem. We know that setting a default from an attribute works, we have hundreds of test cases that check for this and there is thousands of lines of code out in the wild where this works fine. I am not seeing something immediately obvious in the code you have shown.

Sorry,

- Stevan



On Mar 5, 2010, at 9:49 AM, Emmanuel Quevillon wrote:

Stevan Little wrote:

On Mar 5, 2010, at 9:06 AM, Emmanuel Quevillon wrote:
Joel Bernstein wrote:
On 5 Mar 2010, at 13:37, Emmanuel Quevillon wrote:
By the way, I use a self coded 'new' method to create my object.
Would it be the problem?

Yes. But you omitted the code that doesn't work, so... Good luck!

/joel

oops sorry,

sub new {

  my($class, %args) = @_;

  my $self = $class->SUPER::new(%args);

  $self->_init(%args);
  $self->_build_types(%args);
  return $self;
}

Later in the code is try $self->so_type(), nothing is returned...

Honestly, this should work, however you very well might be doing
something in _init or _build_types that causes the problem. Perhaps
showing us some more code would help.

You might also try changing your "new" to this:

sub BUILD {
  my($self, $args) = @_;
  $self->_init(%$args);
  $self->_build_types(%$args);
}

.. which is a little more Moosey.

- stevan

I tried without success :

Here are the methods :

sub BUILD {

   my($self, $args) = @_;

   $self->_init(%$args);
   $self->_build_types(%$args);

}


sub _init {

   my($self, %args) = @_;

   my($output, $cut_type, $format, $style) =
       $self->_rearrange([qw/OUTPUT CUT_TYPES FORMAT STYLE/], %args);

   $format   && $self->_set_format   (lc($format));
   $cut_type && $self->_set_cut_types($cut_type);
   $self->_set_style (lc($style) || 'text');
   $self->_set_output($output);

   return $self;
}

sub _build_types {

   my($self, %args) = @_;

   $self->{_types} = [ ];

   foreach my $type (sort { $a cmp $b } @{$self->cut_types()}){
       $type = lc($type);
       my $obj = "Bio::Restriction::Analysis::FramedCut::$type";
       $self->add_type($obj->new(%args));
   }

   return;
}

If I put some print into these method, nothing is printed out on my
screen. Looks like there are not called at all. :(

I'm really lost :(

--
-------------------------
Emmanuel Quevillon
Biological Software and Databases Group
Institut Pasteur
+33 1 44 38 95 98
tuco at_ pasteur dot fr
-------------------------

Reply via email to