reverse r4290 since we -do- -not- currently want these namespaces indexed
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Schema / AtQueryInterval.pm
CommitLineData
25e4a0c4 1package DBIx::Class::Schema::AtQueryInterval;
2
3use Moose;
4
5=head1 NAME
6
7DBIx::Class::Schema::Role::AtQueryInterval; Defines a job control interval.
8
9=head1 SYNOPSIS
10
11The following example shows how to define a job control interval and assign it
12to a particular L<DBIx::Class::Schema::Job> for a L<DBIx::Class::Schema>
13
14 my $job = DBIx::Class::Schema->new(runs => sub { print 'did job'});
15 my $interval = DBIx::Class::Schema::Interval->new(every => 10);
16
17 if($interval->matches($query_count)) {
18 print "I indentified the query count as matching";
19 }
20
21 ## $schema->isa(DBIx::Class::Schema);
22 $schema->create_and_add_at_query_intervals($interval => $job);
23
24=head1 DESCRIPTION
25
26An AtQueryInterval is a plan object that will execute a certain
27
28=head1 ATTRIBUTES
29
30This package defines the following attributes.
31
32=head2 job (DBIx::Class::Schema::Job)
33
34This is the job which will run at the specified query interval
35
36=cut
37
38has 'job' => (
39 is=>'ro',
40 isa=>'DBIx::Class::Schema::Job',
41 required=>1,
42 handles=>['execute'],
43);
44
45
46=head2 interval (Int)
47
48This is the interval we are watching for
49
50=cut
51
52has 'interval' => (
53 is=>'ro',
54 isa=>'DBIx::Class::Schema::QueryInterval',
55 required=>1,
56 handles=>['matches'],
57);
58
59
60=head1 METHODS
61
62This module defines the following methods.
63
64=head2 execute_if_matches ($query_count, @args)
65
66Does the $query_count match the defined interval? Returns a Boolean.
67
68=cut
69
70sub execute_if_matches {
71 my ($self, $query_count, @args) = @_;
72 if($self->matches($query_count)) {
73 return $self->execute(@args);
74 } else {
75 return;
76 }
77}
78
79
80=head1 AUTHORS
81
82See L<DBIx::Class> for more information regarding authors.
83
84=head1 LICENSE
85
86You may distribute this code under the same terms as Perl itself.
87
88=cut
89
90
911;