Commit | Line | Data |
c0e7b4e5 |
1 | package # hide from PAUSE |
2 | DBIx::Class::CDBICompat::Constructor; |
a3018bd3 |
3 | |
4 | use strict; |
5 | use warnings; |
6 | |
7 | sub add_constructor { |
8 | my ($class, $meth, $sql) = @_; |
9 | $class = ref $class if ref $class; |
10 | no strict 'refs'; |
28f7f7d3 |
11 | |
12 | my %attrs; |
13 | $attrs{rows} = $1 if $sql =~ s/LIMIT\s+(.*)\s+$//i; |
14 | $attrs{order_by} = $1 if $sql =~ s/ORDER BY\s+(.*)//i; |
15 | |
a3018bd3 |
16 | *{"${class}::${meth}"} = |
17 | sub { |
18 | my ($class, @args) = @_; |
28f7f7d3 |
19 | return $class->search_literal($sql, @args, \%attrs); |
a3018bd3 |
20 | }; |
21 | } |
22 | |
23 | 1; |