Commit | Line | Data |
c0e7b4e5 |
1 | package # hide from PAUSE |
2 | DBIx::Class::CDBICompat::ColumnCase; |
ea2e61bf |
3 | |
4 | use strict; |
5 | use warnings; |
75a23b3e |
6 | |
ea2e61bf |
7 | sub _register_column_group { |
8 | my ($class, $group, @cols) = @_; |
147dd158 |
9 | return $class->next::method($group => map lc, @cols); |
ea2e61bf |
10 | } |
11 | |
ec77fadc |
12 | sub add_columns { |
13 | my ($class, @cols) = @_; |
c0eb27e8 |
14 | return $class->result_source_instance->add_columns(map lc, @cols); |
ec77fadc |
15 | } |
16 | |
12bbb339 |
17 | sub has_a { |
c79bd6e9 |
18 | my($self, $col, @rest) = @_; |
d4daee7b |
19 | |
c79bd6e9 |
20 | $self->_declare_has_a(lc $col, @rest); |
21 | $self->_mk_inflated_column_accessor($col); |
d4daee7b |
22 | |
c79bd6e9 |
23 | return 1; |
12bbb339 |
24 | } |
25 | |
b8e1e21f |
26 | sub has_many { |
27 | my ($class, $rel, $f_class, $f_key, @rest) = @_; |
75d07914 |
28 | return $class->next::method($rel, $f_class, ( ref($f_key) ? |
29 | $f_key : |
be7fff92 |
30 | lc($f_key) ), @rest); |
b8e1e21f |
31 | } |
32 | |
9f300b1b |
33 | sub get_inflated_column { |
12bbb339 |
34 | my ($class, $get, @rest) = @_; |
147dd158 |
35 | return $class->next::method(lc($get), @rest); |
12bbb339 |
36 | } |
37 | |
9f300b1b |
38 | sub store_inflated_column { |
12bbb339 |
39 | my ($class, $set, @rest) = @_; |
147dd158 |
40 | return $class->next::method(lc($set), @rest); |
12bbb339 |
41 | } |
42 | |
9f300b1b |
43 | sub set_inflated_column { |
12bbb339 |
44 | my ($class, $set, @rest) = @_; |
147dd158 |
45 | return $class->next::method(lc($set), @rest); |
ea2e61bf |
46 | } |
47 | |
510ca912 |
48 | sub get_column { |
ea2e61bf |
49 | my ($class, $get, @rest) = @_; |
147dd158 |
50 | return $class->next::method(lc($get), @rest); |
ea2e61bf |
51 | } |
52 | |
510ca912 |
53 | sub set_column { |
ea2e61bf |
54 | my ($class, $set, @rest) = @_; |
147dd158 |
55 | return $class->next::method(lc($set), @rest); |
510ca912 |
56 | } |
57 | |
58 | sub store_column { |
59 | my ($class, $set, @rest) = @_; |
147dd158 |
60 | return $class->next::method(lc($set), @rest); |
ea2e61bf |
61 | } |
62 | |
63 | sub find_column { |
64 | my ($class, $col) = @_; |
147dd158 |
65 | return $class->next::method(lc($col)); |
ea2e61bf |
66 | } |
67 | |
9387c904 |
68 | # _build_query |
69 | # |
70 | # Build a query hash for find, et al. Overrides Retrieve::_build_query. |
71 | |
72 | sub _build_query { |
73 | my ($self, $query) = @_; |
74 | |
75 | my %new_query; |
76 | $new_query{lc $_} = $query->{$_} for keys %$query; |
77 | |
78 | return \%new_query; |
79 | } |
80 | |
8da46543 |
81 | sub _deploy_accessor { |
82 | my($class, $name, $accessor) = @_; |
e60dc79f |
83 | |
8da46543 |
84 | return if $class->_has_custom_accessor($name); |
e60dc79f |
85 | |
8da46543 |
86 | $class->next::method(lc $name => $accessor); |
87 | return $class->next::method($name => $accessor); |
12bbb339 |
88 | } |
89 | |
8da46543 |
90 | |
12bbb339 |
91 | sub new { |
92 | my ($class, $attrs, @rest) = @_; |
93 | my %att; |
94 | $att{lc $_} = $attrs->{$_} for keys %$attrs; |
147dd158 |
95 | return $class->next::method(\%att, @rest); |
ea2e61bf |
96 | } |
97 | |
98 | 1; |