1 package Catalyst::Config;
4 use Catalyst::Utils ();
5 use namespace::autoclean;
9 # Uncomment once sane to do so
10 #Carp::cluck("config method called on instance") if ref $self;
11 my $config = $self->_config || {};
13 my $newconfig = { %{@_ > 1 ? {@_} : $_[0]} };
15 $self->merge_config_hashes( $config, $newconfig )
18 # this is a bit of a kludge, required to make
19 # __PACKAGE__->config->{foo} = 'bar';
21 # TODO maybe this should be a ClassData option?
22 my $class = blessed($self) || $self;
23 my $meta = Class::MOP::get_metaclass_by_name($class);
24 unless ($meta->has_package_symbol('$_config')) {
25 # Call merge_hashes to ensure we deep copy the parent
26 # config onto the subclass
27 $self->_config( Catalyst::Utils::merge_hashes($config, {}) );
30 return $self->_config;
33 sub merge_config_hashes {
34 my ( $self, $lefthash, $righthash ) = @_;
36 return Catalyst::Utils::merge_hashes( $lefthash, $righthash );