From: Matt S Trout Date: Mon, 25 Jul 2011 15:09:07 +0000 (+0000) Subject: rewrite _where_to_dq to get rid of refkind switch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=da47d1711d15ac862b2064b6bc2faf851a197996;p=dbsrgits%2FSQL-Abstract.git rewrite _where_to_dq to get rid of refkind switch --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 8843e51..0033758 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -503,10 +503,19 @@ sub _recurse_where { sub _where_to_dq { my ($self, $where, $logic) = @_; - # dispatch on appropriate method according to refkind of $where - my $method = $self->_METHOD_FOR_refkind("_where_to_dq", $where); - - return $self->$method($where, $logic); + if (ref($where) eq 'ARRAY') { + return $self->_where_to_dq_ARRAYREF($where, $logic); + } elsif (ref($where) eq 'HASH') { + return $self->_where_to_dq_HASHREF($where, $logic); + } elsif ( + ref($where) eq 'SCALAR' + or (ref($where) eq 'REF' and ref($$where) eq 'ARRAY') + ) { + return $self->_literal_to_dq($$where); + } elsif (!ref($where)) { + return $self->_value_to_dq($where); + } + die "Can't handle $where"; } sub _where_to_dq_ARRAYREF { @@ -538,16 +547,6 @@ sub _where_to_dq_ARRAYREF { }; } -sub _where_to_dq_ARRAYREFREF { - my ($self, $where) = @_; - return $self->_literal_to_dq($$where); -} - -sub _where_to_dq_SCALARREF { - my ($self, $where) = @_; - return $self->_literal_to_dq($$where); -} - sub _where_to_dq_HASHREF { my ($self, $where, $logic) = @_;