KiokuX-Model-0.02/0000755000076500000240000000000011234220037014103 5ustar nothingmuchstaffKiokuX-Model-0.02/Changes0000644000076500000240000000007711234217772015416 0ustar nothingmuchstaff0.02 - use MooseX::StrictConstructor 0.01 - Initial release KiokuX-Model-0.02/lib/0000755000076500000240000000000011234220035014647 5ustar nothingmuchstaffKiokuX-Model-0.02/lib/KiokuX/0000755000076500000240000000000011234220035016061 5ustar nothingmuchstaffKiokuX-Model-0.02/lib/KiokuX/Model.pm0000644000076500000240000000644611234220013017465 0ustar nothingmuchstaffpackage KiokuX::Model; use Moose; use MooseX::StrictConstructor; use Carp qw(croak); use KiokuDB; use namespace::clean -except => 'meta'; our $VERSION = "0.02"; sub BUILD { my $self = shift; $self->directory; } has dsn => ( isa => "Str", is => "ro", ); has extra_args => ( isa => "HashRef|ArrayRef", is => "ro", predicate => "has_extra_args", ); has typemap => ( isa => "KiokuDB::TypeMap", is => "ro", predicate => "has_typemap", ); has directory => ( isa => "KiokuDB", lazy_build => 1, handles => 'KiokuDB::Role::API', ); sub _build_directory { my $self = shift; KiokuDB->connect(@{ $self->_connect_args }); } has _connect_args => ( isa => "ArrayRef", is => "ro", lazy_build => 1, ); sub _build__connect_args { my $self = shift; my @args = ( $self->dsn || croak "dsn is required" ); if ( $self->has_typemap ) { push @args, typemap => $self->typemap; } if ( $self->has_extra_args ) { my $extra = $self->extra_args; if ( ref($extra) eq 'ARRAY' ) { push @args, @$extra; } else { push @args, %$extra; } } \@args; } sub connect { my ( $class, $dsn, @args ) = @_; $class->new( dsn => $dsn, extra_args => \@args ); } __PACKAGE__->meta->make_immutable; __PACKAGE__ __END__ =pod =head1 NAME KiokuX::Model - A simple application specific wrapper for L. =head1 SYNOPSIS # start with the base class: KiokuX::Model->new( dsn => "bdb:dir=/var/myapp/db" ); # later you can add convenience methods by subclassing: package MyApp::DB; use Moose; extends qw(KiokuX::Model); sub add_user { my ( $self, @args ) = @_; my $user = MyApp::User->new(@args); $self->txn_do(sub { $self->insert($user); }); return $user; } # Then just use it like this: MyApp::DB->new( dsn => "bdb:dir=/var/myapp/db" ); # or automatically using e.g. L: $c->model("kiokudb"); =head1 DESCRIPTION This base class makes it easy to create L database instances in your application. It provides a standard way to instantiate and use a L object in your apps. As your app grows you can subclass it and provide additional convenience methods, without changing the structure of the code, but simply swapping your subclass for L in e.g. L or whatever you use to glue it in. =head1 ATTRIBUTES =over 4 =item directory The instantiated directory. Created using the other attributes at C time. This attribute has delegations set up for all the methods of the L class. =item dsn e.g. C. See L. =item extra_args Additional arguments to pass to C. Can be a hash reference or an array reference. =item typemap An optional custom typemap to add. See L and L. =back =head1 SEE ALSO L, L, L =head1 VERSION CONTROL KiokuDB is maintained using Git. Information about the repository is available on L =head1 AUTHOR Yuval Kogman Enothingmuch@woobling.orgE =head1 COPYRIGHT Copyright (c) 2009 Yuval Kogman, Infinity Interactive. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. = KiokuX-Model-0.02/Makefile.PL0000644000076500000240000000051011234217741016061 0ustar nothingmuchstaff#!/usr/bin/perl -w use strict; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'KiokuX::Model', VERSION_FROM => 'lib/KiokuX/Model.pm', INSTALLDIRS => 'site', SIGN => 1, PL_FILES => { }, PREREQ_PM => { 'KiokuDB' => 0.24, 'MooseX::StrictConstructor' => 0.08, }, ); KiokuX-Model-0.02/MANIFEST0000644000076500000240000000040011234220035015224 0ustar nothingmuchstaffChanges lib/KiokuX/Model.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP t/basic.t META.yml Module meta-data (added by MakeMaker) SIGNATURE Public-key signature (added by MakeMaker) KiokuX-Model-0.02/MANIFEST.SKIP0000644000076500000240000000112511152263222016002 0ustar nothingmuchstaff# Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \b_darcs\b # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ # Avoid Devel::Cover files. \bcover_db\b ### DEFAULT MANIFEST.SKIP ENDS HERE #### \.DS_Store$ \.sw.$ (\w+-)*(\w+)-\d\.\d+(?:\.tar\.gz)?$ \.t\.log$ \.prove$ # XS shit \.(?:bs|c|o)$ KiokuX-Model-0.02/META.yml0000644000076500000240000000102611234220035015351 0ustar nothingmuchstaff--- #YAML:1.0 name: KiokuX-Model version: 0.02 abstract: ~ author: [] license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: KiokuDB: 0.24 MooseX::StrictConstructor: 0.08 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.52 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 KiokuX-Model-0.02/SIGNATURE0000644000076500000240000000214411234220037015370 0ustar nothingmuchstaffThis file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.55. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 0f533c1eaad08dcae2461a6f29ad2c7c5c0854e0 Changes SHA1 2316325c42c61439ad29a4df2ae6237b83b487ee MANIFEST SHA1 190e9058eb9c6446a1a3f3ddf15b082f1ecde152 MANIFEST.SKIP SHA1 ddbac05b89d269cfd687010b0c668cba14288d02 META.yml SHA1 50348f5be752a55092b464b8c5f5974d4a1946b5 Makefile.PL SHA1 86cd5a3973613ee6b9f4aba1f5b275c55e1ec834 lib/KiokuX/Model.pm SHA1 b06b35c8d1a7c1eb22bfa91850b8ae3395950c9a t/basic.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) iD8DBQFKcSAdVCwRwOvSdBgRAn4TAJoDf//qJoHrBWEOm6fVkoO3sd162gCfaBWZ E0q88nZ6Uf+jEublEE+0B0M= =Zohy -----END PGP SIGNATURE----- KiokuX-Model-0.02/t/0000755000076500000240000000000011234220035014344 5ustar nothingmuchstaffKiokuX-Model-0.02/t/basic.t0000644000076500000240000000046011175661357015636 0ustar nothingmuchstaff#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use ok 'KiokuX::Model'; my $m = KiokuX::Model->connect("hash"); isa_ok( $m, "KiokuX::Model" ); is( $m->dsn, "hash" ); can_ok( $m, qw( lookup store update insert clear_live_objects ) ); isa_ok( $m->directory, "KiokuDB" );