[Jifty-commit] r5417 - in Net-Jifty: .
Jifty commits
jifty-commit at lists.jifty.org
Thu May 8 01:17:57 EDT 2008
Author: sartak
Date: Thu May 8 01:17:55 2008
New Revision: 5417
Modified:
Net-Jifty/ (props changed)
Net-Jifty/lib/Net/Jifty.pm
Log:
r55420 at onn: sartak | 2008-05-08 01:16:55 -0400
Break name_model_class out into a method so it may be used as often as needed (and subclasses still have easy control over what gets named what)
Modified: Net-Jifty/lib/Net/Jifty.pm
==============================================================================
--- Net-Jifty/lib/Net/Jifty.pm (original)
+++ Net-Jifty/lib/Net/Jifty.pm Thu May 8 01:17:55 2008
@@ -939,29 +939,17 @@
return $user->{email};
}
-=head2 create_model_class Name[, ClassName] -> ClassName
+=head2 create_model_class Name -> ClassName
-Creates a new model class for the given Name. You may pass in a ClassName if
-you already have a subclass of L<Net::Jifty::Record>.
+Creates a new model class for the given Name.
=cut
sub create_model_class {
my $self = shift;
my $model = shift;
- my $class = shift;
- my ($last) = $model =~ /.*::(.*)/;
- $last = $model if !$last; # no ::
-
- if (!$class) {
- if (blessed($self) eq 'Net::Jifty') {
- $class = "Net::Jifty::Record::$last";
- }
- else {
- $class = blessed($self) . "::$last";
- }
- }
+ my $class = $self->name_model_class($model);
if ($class->can('_net_jifty_model_class_created')) {
return $class->meta->name;
@@ -1000,7 +988,7 @@
}
$meta->add_attribute('+_model_class',
- default => $last,
+ default => $model,
);
$meta->make_immutable;
@@ -1068,6 +1056,20 @@
return undef;
}
+sub name_model_class {
+ my $self = shift;
+ my $model = shift;
+
+ my ($last) = $model =~ /.*::(.*)/;
+ $last = $model if !$last; # no ::
+
+ if (blessed($self) eq 'Net::Jifty') {
+ return "Net::Jifty::Record::$last";
+ }
+
+ return blessed($self) . "::$last";
+}
+
=head1 SEE ALSO
L<Jifty>, L<Net::Hiveminder>
More information about the Jifty-commit
mailing list