That doesn't work
for me.
I get "Attribute (dbh) does not pass the type constraint because:
Validation failed for 'DBI::db' with value CODE(0xa399e40) (not isa
DBI::db)".
So, it appears to be version dependent.
I have perl 5.8.8, Moose 1.24 and CHI 0.50
Unfortunately I cannot upgrade per, Moose easily
On Sat Dec 10 09:23:38 2011, JSWARTZ wrote:
Show quoted text> Are you sure your $dbh is valid? The script below worked for me and
> there is a test for it in
> CHI::Driver::DBI::t::CHIDriverTests::Base::test_with_dbi_generator.
>
> #!/usr/bin/perl
> use CHI;
> use DBI;
> use warnings;
> use strict;
>
> my $dbh = DBI->connect('dbi:SQLite:dbname=dbfile.db', '', '');
> my $cache = CHI->new( driver => 'DBI', dbh => sub { $dbh },
> create_table => 1 );
> $cache->set(foo => 5);
> print $cache->get('foo');
>
>
> On Wed Dec 07 07:54:41 2011, JIRA wrote:
> > The documentation states that you can pass a sub reference as a value
> > for the dbh parameter:
> >
> > 'a code reference that will be called each time and is expected to
> > return a DBI handle, e.g.'.
> >
> > But it is not so. Attempting to do so will cause an error as the
> > parameter is checked to be 'DBI::db'.
>