package DBIxODBC; use Mouse::Role; use MyTypes; use DBIx::Simple; requires qw( user passwd dsn ); with qw(Timestamp); has 'data' => ( is => 'rw', isa => 'HashRef', trigger => \&_load, ); has '_dbix' => ( is => 'ro', isa => 'MyCompany::DBIx', handles => [qw( insert)], builder => '_build_dbix', init_arg => undef, lazy => 1, ); sub _build_dbix() { my $self = shift; my $connect_string; $connect_string = "dbi:ODBC:" . $self->dsn; DBIx::Simple->new( $connect_string, $self->user, $self->passwd ); } sub _load() { my ( $self, $input ) = @_; my $table = ( keys %$input )[0]; $self->insert( $table, $input->{$table} ); print $self->timestamp . qq(\n); } 1;