[Bps-public-commit] r16291 - in Prophet/trunk: .
jesse at bestpractical.com
jesse at bestpractical.com
Tue Oct 14 17:54:14 EDT 2008
Author: jesse
Date: Tue Oct 14 17:54:13 2008
New Revision: 16291
Modified:
Prophet/trunk/ (props changed)
Prophet/trunk/lib/Prophet/App.pm
Log:
r46834 at 16: jesse | 2008-10-14 20:14:23 +0200
* extract 'database_settings' to prophet core
Modified: Prophet/trunk/lib/Prophet/App.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/App.pm (original)
+++ Prophet/trunk/lib/Prophet/App.pm Tue Oct 14 17:54:13 2008
@@ -122,16 +122,38 @@
}
-sub set_database_defaults { 1; }
+sub set_database_defaults {
+ my $self = shift;
+ my $settings = $self->database_settings;
+ for my $name ( keys %$settings ) {
+ my @metadata = @{$settings->{$name}};
+ my $s = $self->setting( label => $name, uuid => (shift @metadata), default => [@metadata]);
+ $s->initialize;
+ }
+}
sub setting {
my $self = shift;
- my %args = validate(@_, { uuid => 1, default => 1, label => 0 });
+ my %args = validate( @_, { uuid => 0, default => 1, label => 0 } );
require Prophet::DatabaseSetting;
- return Prophet::DatabaseSetting->new( handle => $self->handle, uuid => $args{uuid}, default => $args{default}, label => $args{label});
-}
+ my $uuid;
+
+ if ( $args{uuid} ) {
+ $uuid = $args{'uuid'};
+ } elsif ( $args{'label'} ) {
+ $uuid = $self->database_settings->{ $args{'label'} };
+ }
+ return Prophet::DatabaseSetting->new(
+ handle => $self->handle,
+ uuid => $uuid,
+ default => $args{default},
+ label => $args{label}
+ );
+
+}
+sub database_settings {} # XXX wants a better name
__PACKAGE__->meta->make_immutable;
no Moose;
More information about the Bps-public-commit
mailing list