}
##### sub models
-sub friends { return shift->_get_model("_friends", '::Users::Friends'); }
-sub prefs { return shift->_get_model("_prefs", '::Users::Prefs'); }
-sub configs { return shift->_get_model("_configs", '::Users::Configs'); }
-sub achievements { return shift->_get_model("_achievements", '::Users::Achievements'); }
-sub passwords { return shift->_get_model("_passwords", '::Users::Passwords'); }
-sub info { return shift->_get_model("_info", '::Users::Info'); }
-sub acl { return shift->_get_model("_acl", '::Users::ACL'); }
-sub acl2 { return shift->_get_model("_acl2", '::Users::ACL2'); }
-sub comments { return shift->_get_model("_comments", '::Users::Comments'); }
-sub sidebar { return shift->_get_model("_sidebar", '::Users::Sidebar'); }
-sub messages { return shift->_get_model("_messages", '::Users::Messages'); }
-sub index { return shift->_get_model("_index", '::Users::Index'); }
-sub class { return shift->_get_model("_class", '::Users::Class'); }
-sub param { return shift->_get_model("_param", '::Users::Param'); }
-sub permissions { return shift->_get_model("_permissions", '::Users::Permissions'); }
+sub friends { return shift->_get_model('::Users::Friends'); }
+sub prefs { return shift->_get_model('::Users::Prefs'); }
+sub configs { return shift->_get_model('::Users::Configs'); }
+sub achievements { return shift->_get_model('::Users::Achievements'); }
+sub passwords { return shift->_get_model('::Users::Passwords'); }
+sub info { return shift->_get_model('::Users::Info'); }
+sub acl { return shift->_get_model('::Users::ACL'); }
+sub acl2 { return shift->_get_model('::Users::ACL2'); }
+sub comments { return shift->_get_model('::Users::Comments'); }
+sub sidebar { return shift->_get_model('::Users::Sidebar'); }
+sub messages { return shift->_get_model('::Users::Messages'); }
+sub index { return shift->_get_model('::Users::Index'); }
+sub class { return shift->_get_model('::Users::Class'); }
+sub param { return shift->_get_model('::Users::Param'); }
+sub permissions { return shift->_get_model('::Users::Permissions'); }
sub _get_model {
- my ($self, $name, $class) = @_;
- if (!$self->{$name}) {
- $self->{$name} = $self->new_instance_of($class);
+ my ($self, $class) = @_;
+ $self->{sub_models} ||= {};
+ if (!$self->{sub_models}->{$class}) {
+ $self->{sub_models}->{$class} = $self->new_instance_of($class);
}
else {
- if ($self->transaction_mode && !$self->{$name}->transaction_mode) {
- $self->{$name}->use_transaction($self->{_tr_dbh});
+ if ($self->transaction_mode && !$self->{sub_models}->{$class}->transaction_mode) {
+ $self->{sub_models}->{$class}->use_transaction($self->{_tr_dbh});
}
}
- return $self->{$name};
+ return $self->{sub_models}->{$class};
}
##### utility functions