package Grammar::DAG::TypeOf;

use warnings;
use strict;


=head1 NAME

Grammar::DAG::Attr - xxx

=head1 VERSION

Version 0.01

=cut

our $VERSION = '0.01';


=head1 SYNOPSIS

Quick summary of what the module does.

Perhaps a little code snippet.

    use Grammar::DAG::TypeOf;

    my $typeof = Grammar::DAG::TypeOf->new;
    $typeof->add($type, $subref);

    my $type = $typeof->type($path);
=head1 EXPORT

A list of functions that can be exported.  You can delete this section
if you don't export anything, such as for a purely object-oriented module.

=head1 SUBROUTINES/METHODS

=head2 new

=cut

my $rules = [
	{'Dir' => sub { -d shift }},
	{'File' => sub { -f shift }},
];

sub new {
	my ($class,$name) = @_;
	my $self = bless({}, $class);

	$self->rules($rules);

	return $self;
}

sub type {
	my ($self,$path) = @_;

	# return type from rules
	foreach (@{$self->rules}) {
		my ($type,$sub) = each %$_;
		print "GOT type $type sub $sub\n";
		print &$sub($path) . "\n";
		return $type if (&$sub($path));
	}
}

sub rules {
	my $self = shift;

	$self->{'rules'} = shift if @_;
	$self->{'rules'};
}

=head1 AUTHOR

Nuno Carvalho, C<< <smash at cpan.org> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-grammar-dag at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Grammar-DAG>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.




=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Grammar::DAG


You can also look for information at:

=over 4

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Grammar-DAG>

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/Grammar-DAG>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/Grammar-DAG>

=item * Search CPAN

L<http://search.cpan.org/dist/Grammar-DAG/>

=back


=head1 ACKNOWLEDGEMENTS


=head1 LICENSE AND COPYRIGHT

Copyright 2010 Nuno Carvalho.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.


=cut

1; # End of Grammar::DAG::Compiler
