| Catalyst-Model-CouchDB documentation | Contained in the Catalyst-Model-CouchDB distribution. |
Catalyst::Model::CouchDB - CouchDB model class for Catalyst
# model
__PACKAGE__->config(
uri => 'http://localhost:5984/',
);
# controller
sub foo : Local {
my ($self, $c) = @_;
eval {
my $doc = $c->model('MyData')->database('foo')->newDoc('bar')->retrieve;
$c->stash->{thingie} = $doc->{dahut};
};
...
}
This model class exposes CouchDB::Client as a Catalyst model.
You can pass the same configuration fields as when you call CouchDB::Client.
All the methods not handled locally are forwarded to CouchDB::Client.
Called from Catalyst.
Robin Berjon <robin @t berjon d.t com>, Julien Gilles <jul.gil@gmail.com>
Please report any bugs or feature requests to bug-catalyst-model-couchdb at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Model-CouchDB.
Copyright 2008 Robin Berjon, all rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
| Catalyst-Model-CouchDB documentation | Contained in the Catalyst-Model-CouchDB distribution. |
package Catalyst::Model::CouchDB; use Moose; extends 'Catalyst::Model'; use namespace::autoclean; use strict; use warnings; use CouchDB::Client; our $VERSION = '0.02'; sub COMPONENT { my ($class, $c, $config) = @_; my $self = $class->next::method(@_); $self->config($config); my $conf = $self->config; $self->{couchdb_client} = CouchDB::Client->new($conf); $c->log->debug("CouchDB::Client instantiated") if $c->debug; return $self; } sub AUTOLOAD { my ($self, @args) = @_; our $AUTOLOAD; return if $AUTOLOAD =~ /::DESTROY$/; (my $meth = $AUTOLOAD) =~ s/^.*:://; return $self->{couchdb_client}->$meth(@args); } 1;