Newer Older
77 lines | 1.709kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::Query;
updatedd pod
Yuki Kimoto authored on 2011-06-12
2
use Object::Simple -base;
update document
yuki-kimoto authored on 2010-01-30
3

            
cleanup
Yuki Kimoto authored on 2011-02-09
4
use Carp 'croak';
cleanup
Yuki Kimoto authored on 2011-04-25
5
use DBIx::Custom::Util '_subname';
cleanup
Yuki Kimoto authored on 2011-02-09
6

            
- insert method id value is ...
Yuki Kimoto authored on 2011-10-25
7
has [qw/sth statement/],
cleanup
Yuki Kimoto authored on 2012-01-20
8
  sql => '',
9
  columns => sub { [] };
cleanup
Yuki Kimoto authored on 2011-02-09
10

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
11
# DEPRECATED!
12
has 'default_filter';
13
sub filters {
cleanup
Yuki Kimoto authored on 2012-01-20
14
  warn "DBIx::Custom::Query filters attribute method is DEPRECATED!";
15
  my $self = shift;
16
  if (@_) {
17
    $self->{filters} = $_[0];
18
    return $self;
19
  }
20
  return $self->{filters};
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
21
}
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
22

            
23
# DEPRECATED!
24
sub tables {
cleanup
Yuki Kimoto authored on 2012-01-20
25
  warn "DBIx::Custom::Query tables attribute method is DEPRECATED!";
26
  my $self = shift;
27
  if (@_) {
28
    $self->{tables} = $_[0];
29
    return $self;
30
  }
31
  return $self->{tables} ||= [];
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
32
}
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
33

            
34
#DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-02-09
35
sub filter {
cleanup
Yuki Kimoto authored on 2012-01-20
36
  Carp::carp "DBIx::Custom::Query filter method is DEPRECATED!";
37
  my $self = shift;
38
  if (@_) {
39
    my $filter = {};
40
    if (ref $_[0] eq 'HASH') {
41
        $filter = $_[0];
42
    }
43
    else {
44
      my $ef = @_ > 1 ? [@_] : $_[0];
45
      for (my $i = 0; $i < @$ef; $i += 2) {
46
        my $column = $ef->[$i];
47
        my $f = $ef->[$i + 1];
48
        if (ref $column eq 'ARRAY') {
49
          for my $c (@$column) { $filter->{$c} = $f }
cleanup
Yuki Kimoto authored on 2011-02-09
50
        }
cleanup
Yuki Kimoto authored on 2012-01-20
51
        else { $filter->{$column} = $f }
52
      }
53
    }
54
    for my $column (keys %$filter) {
55
      my $fname = $filter->{$column};
56
      if (exists $filter->{$column}
57
        && defined $fname
58
        && ref $fname ne 'CODE') 
59
      {
60
        my $filters = $self->{filters} || {};
61
        croak qq{Filter "$fname" is not registered" } . _subname
62
          unless exists $filters->{$fname};
63
        $filter->{$column} = $filters->{$fname};
64
      }
cleanup
Yuki Kimoto authored on 2011-02-09
65
    }
cleanup
Yuki Kimoto authored on 2012-01-20
66
    $self->{filter} = {%{$self->{filter} || {}}, %$filter};
67
    return $self;
68
  }
69
  return $self->{filter} ||= {};
cleanup
Yuki Kimoto authored on 2011-02-09
70
}
cleanup
Yuki Kimoto authored on 2011-01-23
71

            
update document
yuki-kimoto authored on 2010-01-30
72
1;
73

            
packaging one directory
yuki-kimoto authored on 2009-11-16
74
=head1 NAME
75

            
DBIx::Custom::Query is DEPRE...
Yuki Kimoto authored on 2011-11-15
76
DBIx::Custom::Query - DEPRECATED!
packaging one directory
yuki-kimoto authored on 2009-11-16
77