Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

preserve attribute order in N::W::Object::*->new

that way you can construct objects in the order you want.
Using a hash scrambles the order, so use an array instead.
This is important because the RIPE db expects the primary key
to be the first attribute.
  • Loading branch information...
commit e7425ce2c6d1090029b88446cad35facf9601323 1 parent 6ae2964
Moritz Lenz authored
View
15 lib/Net/Whois/Object.pm
@@ -543,6 +543,21 @@ sub _multiple_attribute_setget {
return $self->{$attribute};
}
+=head2 B<_init( @options )>
+
+Initialize self with C<@options>
+
+=cut
+
+sub _init {
+ my ($self, @options) = @_;
+
+ while (my ($key, $val ) = splice(@options, 0, 2)) {
+ $self->$key( $val );
+ }
+}
+
+
=head2 B<_syncupdates_submit( $text, $password )>
Interact with the RIPE database through the web syncupdates interface.
View
7 lib/Net/Whois/Object/AsBlock.pm
@@ -40,13 +40,10 @@ Constructor for the Net::Whois::Object::AsBlock class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['as_block'] );
$self->attributes( 'mandatory', [ 'as_block', 'admin_c', 'tech_c', 'mnt_by', 'changed', 'source' ] );
View
9 lib/Net/Whois/Object/AsSet.pm
@@ -28,20 +28,17 @@ It defines a group of Autonomous Systems with the same routing policies.
=head1 METHODS
-=head2 new ( %options )
+=head2 new ( @options )
Constructor for the Net::Whois::Object::AsSet class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['as_set'] );
$self->attributes( 'mandatory', [ 'as_set', 'descr', 'tech_c', 'admin_c', 'mnt_by', 'changed', 'source' ] );
View
9 lib/Net/Whois/Object/AutNum.pm
@@ -40,20 +40,17 @@ operated by one or more network operators – an Autonomous System (AS).
=head1 METHODS
-=head2 new ( %options )
+=head2 new ( @options )
Constructor for the Net::Whois::Object::AutNum class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['aut_num'] );
$self->attributes( 'mandatory', [ 'aut_num', 'as_name', 'descr', 'tech_c', 'admin_c', 'mnt_by', 'changed', 'source' ] );
View
9 lib/Net/Whois/Object/Domain.pm
@@ -35,20 +35,17 @@ name is written in fully qualified format, without a trailing " . "
=head1 METHODS
-=head2 new ( %options )
+=head2 new ( @options )
Constructor for the Net::Whois::Object::Domain class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['domain'] );
$self->attributes( 'mandatory', [ 'domain', 'descr', 'tech_c', 'admin_c', 'zone_c', 'changed', 'source' ] );
View
9 lib/Net/Whois/Object/FilterSet.pm
@@ -31,20 +31,17 @@ not want to see.
=head1 METHODS
-=head2 new ( %options )
+=head2 new ( @options )
Constructor for the Net::Whois::Object::FilterSet class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['filter_set'] );
$self->attributes( 'mandatory', [ 'filter_set', 'filter', 'mp_filter', 'source' ] );
View
9 lib/Net/Whois/Object/Inet6Num.pm
@@ -38,20 +38,17 @@ of IPv6 address space.
=head1 METHODS
-=head2 new ( %options )
+=head2 new ( @options )
Constructor for the Net::Whois::Object::Inet6Num class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['inet6num'] );
$self->attributes( 'mandatory', [ 'inet6num', 'netname', 'status', 'source' ] );
View
8 lib/Net/Whois/Object/InetNum.pm
@@ -39,20 +39,18 @@ of IPv4 address space.
=head1 METHODS
-=head2 new ( %options )
+=head2 new ( @options )
Constructor for the Net::Whois::Object::InetNum class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['inetnum'] );
$self->attributes( 'mandatory', [ 'inetnum', 'netname', 'descr', 'country', 'tech_c', 'admin_c', 'status', 'mnt_by', 'changed', 'source' ] );
View
9 lib/Net/Whois/Object/InetRtr.pm
@@ -33,20 +33,17 @@ The inet-rtr object specifies routers.
=head1 METHODS
-=head2 new ( %options )
+=head2 new ( @options )
Constructor for the Net::Whois::Object::InetRtr class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['inet_rtr'] );
$self->attributes( 'mandatory', [ 'inet_rtr', 'descr', 'local_as', 'ifaddr', 'tech_c', 'admin_c', 'mnt_by', 'changed', 'source' ] );
View
9 lib/Net/Whois/Object/Information.pm
@@ -21,20 +21,17 @@ information.
=head1 METHODS
-=head2 new ( %options )
+=head2 new ( @options )
Constructor for the Net::Whois::Object::Information class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'mandatory', ['comment'] );
$self->attributes( 'optional', [] );
View
7 lib/Net/Whois/Object/Irt.pm
@@ -46,13 +46,10 @@ Constructor for the Net::Whois::Object::Irt class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['irt'] );
$self->attributes( 'mandatory', [ 'irt', 'address', 'e_mail', 'abuse_mailbox', 'tech_c', 'admin_c', 'auth', 'mnt_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/KeyCert.pm
@@ -38,13 +38,10 @@ Constructor for the Net::Whois::Object::InetRtr class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['key_cert'] );
$self->attributes( 'mandatory', [ 'key_cert', 'certif', 'mnt_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/Limerick.pm
@@ -34,13 +34,10 @@ Constructor for the Net::Whois::Object::Limerick class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['limerick'] );
$self->attributes( 'mandatory', [ 'limerick', 'text', 'admin_c', 'author', 'mnt_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/Mntner.pm
@@ -48,13 +48,10 @@ Constructor for the Net::Whois::Object::Mntner class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['mntner'] );
$self->attributes( 'mandatory', [ 'mntner', 'descr', 'admin_c', 'auth', 'mnt_by', 'referral_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/Organisation.pm
@@ -42,13 +42,10 @@ Constructor for the Net::Whois::Object::Organisation class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['organisation'] );
$self->attributes( 'mandatory', [ 'organisation', 'org_name', 'org_type', 'address', 'e_mail', 'mnt_ref', 'mnt_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/PeeringSet.pm
@@ -40,13 +40,10 @@ Constructor for the Net::Whois::Object::PeeringSet class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['peering_set'] );
$self->attributes( 'mandatory', [ 'peering_set', 'descr', 'peering', 'tech_c', 'admin_c', 'mnt_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/Person.pm
@@ -37,13 +37,10 @@ Constructor for the Net::Whois::Object::Person class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['nic_hdl'] );
$self->attributes( 'mandatory', [ 'person', 'address', 'phone', 'nic_hdl', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/Poem.pm
@@ -36,13 +36,10 @@ Constructor for the Net::Whois::Object::Poem class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['poem'] );
$self->attributes( 'mandatory', [ 'poem', 'form', 'text', 'author', 'admin_c', 'mnt_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/PoeticForm.pm
@@ -34,13 +34,10 @@ Constructor for the Net::Whois::Object::PoeticForm class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['poetic_form'] );
$self->attributes( 'mandatory', [ 'poetic_form', 'admin_c', 'mnt_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/Response.pm
@@ -27,13 +27,10 @@ Constructor for the Net::Whois::Object::Response class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'mandatory', ['response'] );
$self->attributes( 'optional', ['comment'] );
View
7 lib/Net/Whois/Object/Role.pm
@@ -44,13 +44,10 @@ Constructor for the Net::Whois::Object::Role class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['nic_hdl'] );
$self->attributes( 'mandatory', [ 'role', 'address', 'e_mail', 'tech_c', 'admin_c', 'nic_hdl', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/Route.pm
@@ -52,13 +52,10 @@ Constructor for the Net::Whois::Object::Route class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['route'] );
$self->attributes( 'mandatory', [ 'route', 'origin', 'descr', 'mnt_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/Route6.pm
@@ -49,13 +49,10 @@ Constructor for the Net::Whois::Object::Route6 class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['route6'] );
$self->attributes( 'mandatory', [ 'route6', 'origin', 'descr', 'mnt_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/RouteSet.pm
@@ -45,13 +45,10 @@ Constructor for the Net::Whois::Object::RouteSet class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['route_set'] );
$self->attributes( 'mandatory', [ 'route_set', 'descr', 'tech_c', 'admin_c', 'mnt_by', 'changed', 'source' ] );
View
7 lib/Net/Whois/Object/RtrSet.pm
@@ -41,13 +41,10 @@ Constructor for the Net::Whois::Object::RtrSet class
=cut
sub new {
- my ( $class, %options ) = @_;
+ my ( $class, @options ) = @_;
my $self = bless {}, $class;
-
- for my $key ( keys %options ) {
- $self->$key( $options{$key} );
- }
+ $self->_init(@options);
$self->attributes( 'primary', ['rtr_set'] );
$self->attributes( 'mandatory', [ 'rtr_set', 'descr', 'tech_c', 'admin_c', 'mnt_by', 'changed', 'source' ] );
Please sign in to comment.
Something went wrong with that request. Please try again.