| 1 | package Rose::DB::Object::Metadata::Column::Interval; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | |||
| 5 | use Rose::Object::MakeMethods::Generic; | ||
| 6 | use Rose::DB::Object::MakeMethods::Time; | ||
| 7 | |||
| 8 | use Rose::DB::Object::Metadata::Column; | ||
| 9 | our @ISA = qw(Rose::DB::Object::Metadata::Column); | ||
| 10 | |||
| 11 | our $VERSION = '0.788'; | ||
| 12 | |||
| 13 | __PACKAGE__->add_common_method_maker_argument_names('default', 'scale', 'end_of_month_mode'); | ||
| 14 | |||
| 15 | Rose::Object::MakeMethods::Generic->make_methods | ||
| 16 | ( | ||
| 17 | { preserve_existing => 1 }, | ||
| 18 | scalar => [ scale => { default => 0 } ], | ||
| 19 | scalar => [ __PACKAGE__->common_method_maker_argument_names ] | ||
| 20 | ); | ||
| 21 | |||
| 22 | foreach my $type (__PACKAGE__->available_method_types) | ||
| 23 | { | ||
| 24 | __PACKAGE__->method_maker_class($type => 'Rose::DB::Object::MakeMethods::Time'); | ||
| 25 | __PACKAGE__->method_maker_type($type => 'interval'); | ||
| 26 | } | ||
| 27 | |||
| 28 | sub type { 'interval' } | ||
| 29 | |||
| 30 | sub should_inline_value | ||
| 31 | { | ||
| 32 | my($self, $db, $value) = @_; | ||
| 33 | no warnings 'uninitialized'; | ||
| 34 | return (($db->validate_interval_keyword($value) && $db->should_inline_interval_keyword($value)) || | ||
| 35 | ($db->keyword_function_calls && $value =~ /^\w+\(.*\)$/)) ? 1 : 0; | ||
| 36 | } | ||
| 37 | |||
| 38 | sub method_should_set | ||
| 39 | { | ||
| 40 | my($self, $type, $args) = @_; | ||
| 41 | |||
| 42 | return 1 if($type eq 'set' || $type eq 'get_set'); | ||
| 43 | return 0 if($type eq 'get'); | ||
| 44 | |||
| 45 | return $self->SUPER::method_should_set($type, $args); | ||
| 46 | } | ||
| 47 | |||
| 48 | sub parse_value { shift; shift->parse_interval(@_) } | ||
| 49 | sub format_value { shift; shift->format_interval(@_) } | ||
| 50 | |||
| 51 | sub method_uses_formatted_key | ||
| 52 | { | ||
| 53 | my($self, $type) = @_; | ||
| 54 | return 1 if($type eq 'get' || $type eq 'set' || $type eq 'get_set'); | ||
| 55 | return 0; | ||
| 56 | } | ||
| 57 | |||
| 58 | 1; | ||
| 59 | |||
| 60 | __END__ |