From 681344f391f6a752cc96210ecb3216c1f4515363 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Wed, 11 May 2011 22:05:00 -0700 Subject: Support listing all tweakables. --- libpiny/lib/Piny/Config.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libpiny') 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 -- cgit v1.2.3