1 package SL::DefaultManager;
5 use SL::Util qw(camelify);
6 use List::Util qw(first);
11 my ($class, @defaults) = @_;
12 bless [ @defaults ], $class;
18 map { $self->_get($_) } @$self;
22 my ($class, $name) = @_;
26 $manager_cache{$name} ||= do {
27 die "'$name' doesn't look like a default manager." unless $name =~ /^\w+$/;
29 my $package = 'SL::DefaultManager::' . camelify($name);
31 eval "require $package; 1" or die "could not load default manager '$package': $@";
40 my ($self, @args) = @_;
42 my $method = $AUTOLOAD;
44 return if $method eq 'DESTROY';
46 my $manager = first { $_->can($method) } $self->_managers;
48 return $manager ? $manager->$method : @args;
59 SL::DefaultManager - sets of defaults for use outside of clients
64 my $defaults = SL::DefaultManager->new($::lx_office_conf{default_manager});
67 my $defaults = SL::DefaultManager->new('swiss');
70 # will return what the manager provides, or the given value if $defaults does
71 # not handle dateformat
72 my $dateformat = $defaults->dateformat('dd.mm.yyyy');
74 # have several default managers for different tasks
75 # if polled the first defined response will win
76 my $defaults = SL::DefaultManager->new('swiss', 'mobile', 'point_of_sale');
92 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>