--- /dev/null
+use strict;
+use warnings;
+
+use inc::Module::Install 0.79;
+
+requires 'Moose' => '0.71';
+requires 'MooseX::Method::Signatures' => '0.07';
+requires 'MooseX::Declare' => '0.04';
+
+test_requires 'Test::More';
+
+WriteAll;
--- /dev/null
+use MooseX::Declare;
+use MooseX::Method::Signatures;
+
+
+class SQL::Abstract {
+
+ use Carp qw/croak/;
+ use Data::Dump qw/pp/;
+
+ use Moose::Util::TypeConstraints;
+ use MooseX::Types -declare => ['NameSeparator'];
+ use MooseX::Types::Moose qw/ArrayRef Str/;
+
+ subtype NameSeparator,
+ as ArrayRef[Str];
+ #where { @$_ == 1 ||| @$_ == 2 },
+ #message { "Name separator must be one or two elements" };
+
+ coerce NameSeparator, from Str, via { [ $_ ] };
+
+ our $VERSION = '2.000000';
+
+ our $AST_VERSION = '1';
+
+ has name_separator => (
+ is => 'rw',
+ isa => NameSeparator,
+ default => sub { ['.'] },
+ coerece => 1,
+ required => 1,
+ );
+
+ has list_separator => (
+ is => 'rw',
+ isa => Str,
+ default => ', ',
+ required => 1,
+ );
+
+ method generate (ArrayRef $ast) {
+ $self = new $self unless blessed($self);
+
+ local $_ = $ast->[0];
+ s/^-/_/ or croak "Unknown type tag '$_'";
+ return $self->$_($ast);
+ }
+
+ method _name(ArrayRef[Str] $ast) {
+ my (undef, @names) = @$ast;
+
+ my $sep = $self->name_separator;
+
+ return $sep->[0] .
+ join( $sep->[1] . $sep->[0], @names ) .
+ $sep->[1]
+ if (@$sep > 1);
+
+ return join($sep->[0], @names);
+ }
+
+ method _list(ArrayRef $ast) {
+ my (undef, @items) = @$ast;
+
+ return join(
+ $self->list_separator,
+ map { $self->generate($_) } @items);
+
+ }
+
+};
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+use_ok('SQL::Abstract') or BAIL_OUT( "$@" );
+
+is SQL::Abstract->generate( [ -name => qw/me id/]), "me.id",
+ "Simple name generator";
+
+is SQL::Abstract->generate(
+ [ -list =>
+ [ -name => qw/me id/],
+ [ -name => qw/me foo bar/],
+ [ -name => qw/bar/]
+ ]
+), "me.id, me.foo.bar, bar",
+ "List generator";