From: Matt S Trout Date: Sat, 14 Apr 2012 02:48:51 +0000 (+0000) Subject: initial Mooification X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8b4289c84d8ac962d79eba63f795ff440aff309b;p=dbsrgits%2FData-Query.git initial Mooification --- diff --git a/lib/Data/Query/Renderer/SQL/Naive.pm b/lib/Data/Query/Renderer/SQL/Naive.pm index 354036d..31cd462 100644 --- a/lib/Data/Query/Renderer/SQL/Naive.pm +++ b/lib/Data/Query/Renderer/SQL/Naive.pm @@ -9,20 +9,17 @@ use Data::Query::Constants qw( DQ_IDENTIFIER DQ_OPERATOR DQ_VALUE DQ_JOIN DQ_ALIAS DQ_ORDER DQ_LITERAL ); -sub new { - bless({ %{$_[1]||{}} }, (ref($_[0])||$_[0]))->BUILDALL; -} +use Moo; -sub BUILDALL { - my $self = shift; - $self->{reserved_ident_parts} - ||= ( - our $_DEFAULT_RESERVED ||= { map +($_ => 1), SQL::ReservedWords->words } - ); - $self->{quote_chars}||=['']; - $self->{simple_ops}||=$self->_default_simple_ops; - return $self; -} +has reserved_ident_parts => ( + is => 'ro', default => sub { + our $_DEFAULT_RESERVED ||= { map +($_ => 1), SQL::ReservedWords->words } + } +); + +has quote_chars => (is => 'ro', default => sub { [''] }); + +has simple_ops => (is => 'ro', builder => '_default_simple_ops'); sub _default_simple_ops { +{ @@ -89,9 +86,9 @@ sub _render_identifier { die "Unidentified identifier (SQL can no has \$_)" unless my @i = @{$_[1]->{elements}}; # handle single or paired quote chars - my ($q1, $q2) = @{$_[0]->{quote_chars}}[0,-1]; + my ($q1, $q2) = @{$_[0]->quote_chars}[0,-1]; my $always_quote = $_[0]->{always_quote}; - my $res_check = $_[0]->{reserved_ident_parts}; + my $res_check = $_[0]->reserved_ident_parts; return [ join $_[0]->{identifier_sep}||'.',