This file is indexed.

/usr/share/perl5/KiokuX/Model.pm is in libkiokux-model-perl 0.02-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package 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<KiokuDB>.

=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<Catalyst::Model::KiokuDB>:

	$c->model("kiokudb");

=head1 DESCRIPTION

This base class makes it easy to create L<KiokuDB> database instances in your
application. It provides a standard way to instantiate and use a L<KiokuDB>
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<KiokuX::Model> in e.g. L<Catalyst::Model::KiokuDB> or whatever
you use to glue it in.

=head1 ATTRIBUTES

=over 4

=item directory

The instantiated directory.

Created using the other attributes at C<BUILD> time.

This attribute has delegations set up for all the methods of the L<KiokuDB>
class.

=item dsn

e.g. C<bdb:dir=root/db>. See L<KiokuDB/connect>.

=item extra_args

Additional arguments to pass to C<connect>.

Can be a hash reference or an array reference.

=item typemap

An optional custom typemap to add. See L<KiokuDB::Typemap> and
L<KiokuDB/typemap>.

=back

=head1 SEE ALSO

L<KiokuDB>, L<KiokuDB::Role::API>, L<Catalyst::Model::KiokuDB>

=head1 VERSION CONTROL

KiokuDB is maintained using Git. Information about the repository is available
on L<http://www.iinteractive.com/kiokudb/>

=head1 AUTHOR

Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>

=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.

=