Catalyst::Model::CouchDB - CouchDB model class for Catalyst


Catalyst-Model-CouchDB documentation Contained in the Catalyst-Model-CouchDB distribution.

Index


Code Index:

NAME

Top

Catalyst::Model::CouchDB - CouchDB model class for Catalyst

SYNOPSIS

Top

    # 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};
        };
        ...
    }




DESCRIPTION

Top

This model class exposes CouchDB::Client as a Catalyst model.

CONFIGURATION

Top

You can pass the same configuration fields as when you call CouchDB::Client.

METHODS

Top

CouchDB

All the methods not handled locally are forwarded to CouchDB::Client.

new

Called from Catalyst.

AUTHOR

Top

Robin Berjon <robin @t berjon d.t com>, Julien Gilles <jul.gil@gmail.com>

BUGS

Top

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 & LICENSE

Top


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;