aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/InterfaceModel/Reflector/DBIC.pm
diff options
context:
space:
mode:
authorwreis <wreis@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-01-30 02:41:25 +0000
committerwreis <wreis@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-01-30 02:41:25 +0000
commit46937531eb2d28950b21c8b0982539e28b277b60 (patch)
treebce5cca8a3b521a3e4be5b9fc64d43934bdc32c4 /lib/Reaction/InterfaceModel/Reflector/DBIC.pm
parent1c41e332e495bee30ba8c31d44023fddb7e2602b (diff)
downloadreaction-46937531eb2d28950b21c8b0982539e28b277b60.tar.gz
reaction-46937531eb2d28950b21c8b0982539e28b277b60.zip
added _class_to_attribute_name method
Diffstat (limited to 'lib/Reaction/InterfaceModel/Reflector/DBIC.pm')
-rw-r--r--lib/Reaction/InterfaceModel/Reflector/DBIC.pm9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm
index 1acc967..b52d485 100644
--- a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm
+++ b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm
@@ -279,6 +279,11 @@ class DBIC, which {
};
};
+ implements _class_to_attribute_name => as {
+ my ( $self, $str ) = @_;
+ confess("wrong arguments passed for _class_to_attribute_name") unless $str;
+ return join('_', map lc, split(/::|(?<=[a-z0-9])(?=[A-Z])/, $str))
+ };
implements add_source => as {
my ($self, %opts) = @_;
@@ -301,7 +306,7 @@ class DBIC, which {
unless( $reader ){
$reader = $source;
$reader =~ s/([a-z0-9])([A-Z])/${1}_${2}/g ;
- $reader = join('_', map lc, split(/::/, $reader)) . "_collection"; #XXX change to not use _collection ?
+ $reader = $self->_class_to_attribute_name($reader) . "_collection";
}
unless( $dm_name ){
my @haystack = $meta->domain_models;
@@ -324,7 +329,7 @@ class DBIC, which {
required => 1,
isa => $collection,
reader => $reader,
- predicate => "has_" . join('_', map lc, split(/::|(?<=[a-z0-9])(?=[A-Z])/, $name)),
+ predicate => "has_" . $self->_class_to_attribute_name($name) ,
domain_model => $dm_name,
orig_attr_name => $source,
default => sub {