From: Michael G Schwern Date: Fri, 14 Mar 2008 02:01:20 +0000 (+0000) Subject: Move has_a() code out of ColumnCase. That should be the last of it. X-Git-Tag: v0.08240~521 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c79bd6e9b40607d08e41879ecad0804c38bf14dc;p=dbsrgits%2FDBIx-Class.git Move has_a() code out of ColumnCase. That should be the last of it. --- diff --git a/lib/DBIx/Class/CDBICompat/ColumnCase.pm b/lib/DBIx/Class/CDBICompat/ColumnCase.pm index 410fded..a7c62a9 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnCase.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnCase.pm @@ -17,10 +17,12 @@ sub add_columns { } sub has_a { - my ($class, $col, @rest) = @_; - $class->next::method(lc($col), @rest); - $class->mk_group_accessors('inflated_column' => $col); - return 1; + my($self, $col, @rest) = @_; + + $self->_declare_has_a(lc $col, @rest); + $self->_mk_inflated_column_accessor($col); + + return 1; } sub has_many { diff --git a/lib/DBIx/Class/CDBICompat/Relationships.pm b/lib/DBIx/Class/CDBICompat/Relationships.pm index 77bc788..0a4b475 100644 --- a/lib/DBIx/Class/CDBICompat/Relationships.pm +++ b/lib/DBIx/Class/CDBICompat/Relationships.pm @@ -23,8 +23,19 @@ Emulate C, C, C and C. =cut sub has_a { + my($self, $col, @rest) = @_; + + $self->_declare_has_a($col, @rest); + $self->_mk_inflated_column_accessor($col); + + return 1; +} + + +sub _declare_has_a { my ($self, $col, $f_class, %args) = @_; - $self->throw_exception( "No such column ${col}" ) unless $self->has_column($col); + $self->throw_exception( "No such column ${col}" ) + unless $self->has_column($col); $self->ensure_class_loaded($f_class); my $rel_info; @@ -55,10 +66,15 @@ sub has_a { has_a => $col, $rel_info ); - + return 1; } +sub _mk_inflated_column_accessor { + my($class, $col) = @_; + + return $class->mk_group_accessors('inflated_column' => $col); +} sub has_many { my ($class, $rel, $f_class, $f_key, $args) = @_;