package SQL::Abstract::Tree;
-use strict;
-use warnings;
-no warnings 'qw';
use Carp;
+use Hash::Merge ();
+
+use Sub::Quote 'quote_sub';
+use Moo;
+no warnings 'qw';
-use Hash::Merge qw//;
+has [qw(
+ newline indent_string indent_amount fill_in_placeholders
+)] => ( is => 'rw' );
-use base 'Class::Accessor::Grouped';
+has [qw(
+ colormap indentmap
+)] => ( is => 'rw', default => quote_sub('{}') );
-__PACKAGE__->mk_group_accessors( simple => qw(
- newline indent_string indent_amount colormap indentmap fill_in_placeholders
- placeholder_surround
-));
+has [qw(
+ placeholder_surround
+)] => ( is => 'rw', default => quote_sub('[]') );
my $merger = Hash::Merge->new;
},
);
-sub new {
- my $class = shift;
- my $args = shift || {};
-
- my $profile = delete $args->{profile} || 'none';
-
- die "No such profile '$profile'!" unless exists $profiles{$profile};
+sub BUILDARGS {
+ my $class = shift;
+ my $args = { (ref $_[0] eq 'HASH') ? %{$_[0]} : @_ };
+ my $profile = delete $args->{profile} || 'none';
- my $data = $merger->merge( $profiles{$profile}, $args );
+ die "No such profile '$profile'!" unless exists $profiles{$profile};
- bless $data, $class
+ return $merger->merge( $profiles{$profile}, $args );
}
sub parse {