mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 21:51:21 +00:00
45 lines
790 B
Perl
45 lines
790 B
Perl
{
|
|
package Lmo::Meta;
|
|
use strict;
|
|
use warnings qw( FATAL all );
|
|
|
|
my %metadata_for;
|
|
|
|
sub new {
|
|
my $class = shift;
|
|
return bless { @_ }, $class
|
|
}
|
|
|
|
sub metadata_for {
|
|
my $self = shift;
|
|
my ($class) = @_;
|
|
|
|
return $metadata_for{$class} ||= {};
|
|
}
|
|
|
|
sub class { shift->{class} }
|
|
|
|
sub attributes {
|
|
my $self = shift;
|
|
return keys %{$self->metadata_for($self->class)}
|
|
}
|
|
|
|
sub attributes_for_new {
|
|
my $self = shift;
|
|
my @attributes;
|
|
|
|
my $class_metadata = $self->metadata_for($self->class);
|
|
while ( my ($attr, $meta) = each %$class_metadata ) {
|
|
if ( exists $meta->{init_arg} ) {
|
|
push @attributes, $meta->{init_arg}
|
|
if defined $meta->{init_arg};
|
|
}
|
|
else {
|
|
push @attributes, $attr;
|
|
}
|
|
}
|
|
return @attributes;
|
|
}
|
|
|
|
1;
|
|
} |