saintex has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I would like to extends a package in order to have some default values.
The module I would like to extend is WWW::Selenium .
I would like to extend the package in my code, just to have some defualt values.
Ususally you call WWW::Selenium like this:
So I tried to write an extension:
But it doesn't work. Without arguments I have an error.
Where I'm wrong?
I would like to extends a package in order to have some default values.
The module I would like to extend is WWW::Selenium .
I would like to extend the package in my code, just to have some defualt values.
Ususally you call WWW::Selenium like this:
I would like to call it just with new, without args:my $b=Selenium->new( host => "localhost", port => 4444, browser => "*firefox", browser_url => 'http://www.google.co +m', );
So I tried to write an extension:
package Selenium; our $VERSION=0.01; use 5.010; use Moose; use MooseX::NonMoose; use Test::WWW::Selenium; extends 'Test::WWW::Selenium'; around BUILDARGS => sub { my $orig = shift; my $class = shift; my %args = ( @_ == 1 ? %{ $_[0] } : @_ ); $args{host}//="localhost"; $args{port}//=4444; $args{browser}//="*firefox"; $args{browser_url}//='http://wwww.google.com'; return $class->$orig(%args); }; sub BUILD { my $self = shift; #$self->start; }
But it doesn't work. Without arguments I have an error.
Where I'm wrong?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Problem with around BUILDARGS
by stvn (Monsignor) on Mar 24, 2011 at 13:32 UTC | |
by saintex (Scribe) on Mar 24, 2011 at 14:29 UTC | |
by saintex (Scribe) on Mar 28, 2011 at 10:58 UTC | |
by stvn (Monsignor) on Mar 28, 2011 at 17:01 UTC | |
by saintex (Scribe) on Mar 29, 2011 at 14:23 UTC | |
by saintex (Scribe) on Apr 19, 2011 at 16:45 UTC | |
by stvn (Monsignor) on Apr 21, 2011 at 00:49 UTC | |
|
Back to
Seekers of Perl Wisdom