diff options
author | Julian Blake Kongslie <jblake@omgwallhack.org> | 2011-05-11 22:05:00 -0700 |
---|---|---|
committer | Julian Blake Kongslie <jblake@omgwallhack.org> | 2011-05-11 22:05:00 -0700 |
commit | 681344f391f6a752cc96210ecb3216c1f4515363 (patch) | |
tree | ca848d213f67e9391ad1861330d527e3a226c18b /libpiny/lib/Piny | |
parent | 3ca6564c2d95d12dff83cc645c280aa734ad19f8 (diff) | |
download | piny-code-681344f391f6a752cc96210ecb3216c1f4515363.tar.gz piny-code-681344f391f6a752cc96210ecb3216c1f4515363.zip |
Support listing all tweakables.
Diffstat (limited to 'libpiny/lib/Piny')
-rw-r--r-- | libpiny/lib/Piny/Config.pm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libpiny/lib/Piny/Config.pm b/libpiny/lib/Piny/Config.pm index 9f43c19..d37fa67 100644 --- a/libpiny/lib/Piny/Config.pm +++ b/libpiny/lib/Piny/Config.pm @@ -162,6 +162,24 @@ sub save { $cs->write( $s->confpath ); }; +# Dump all tweakables + +my @tweakables = ( ); + +sub all_tweakables { + my ( $s ) = @_; + + my $r = { }; + + foreach my $t ( @tweakables ) { + eval { + $r->{$t} = $s->$t; + }; + }; + + return $r; +}; + # Tweakable helper sub tweakable { @@ -174,6 +192,8 @@ sub tweakable { if ( $attrname =~ /_/ ) { croak "Illegal attribute name $attrname! (use only one underbar)"; }; + push @tweakables, $attr; + has $attr => ( is => 'rw' , isa => $isa |