| 1 | |||
| 2 | package DBIx::Romani::Query::Select::OrderBy; | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | |||
| 6 | sub new | ||
| 7 | { | ||
| 8 | my $class = shift; | ||
| 9 | my $args = shift; | ||
| 10 | |||
| 11 | my $value; | ||
| 12 | my $dir; | ||
| 13 | |||
| 14 | if ( ref($args) eq 'HASH' ) | ||
| 15 | { | ||
| 16 | $value = $args->{value}; | ||
| 17 | $dir = $args->{dir}; | ||
| 18 | } | ||
| 19 | else | ||
| 20 | { | ||
| 21 | $value = $args; | ||
| 22 | $dir = shift; | ||
| 23 | } | ||
| 24 | |||
| 25 | if ( not defined $dir ) | ||
| 26 | { | ||
| 27 | $dir = "asc"; | ||
| 28 | } | ||
| 29 | |||
| 30 | my $self = { | ||
| 31 | value => $value, | ||
| 32 | dir => $dir | ||
| 33 | }; | ||
| 34 | |||
| 35 | bless $self, $class; | ||
| 36 | return $self; | ||
| 37 | } | ||
| 38 | |||
| 39 | sub get_dir { return shift->{dir}; } | ||
| 40 | sub get_value { return shift->{value}; } | ||
| 41 | |||
| 42 | sub clone | ||
| 43 | { | ||
| 44 | my $self = shift; | ||
| 45 | |||
| 46 | my $args = { | ||
| 47 | value => $self->get_value(), | ||
| 48 | dir => $self->get_dir() | ||
| 49 | }; | ||
| 50 | |||
| 51 | return DBIx::Romani::Query::Select::OrderBy->new($args); | ||
| 52 | } | ||
| 53 | |||
| 54 | 1; | ||
| 55 |