| 1 | package Rose::DB::Object::Metadata::Column::Set; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | |||
| 5 | use Rose::Object::MakeMethods::Generic; | ||
| 6 | use Rose::DB::Object::MakeMethods::Generic; | ||
| 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 | ||
| 14 | ( | ||
| 15 | qw(default check_in value_type) | ||
| 16 | ); | ||
| 17 | |||
| 18 | Rose::Object::MakeMethods::Generic->make_methods | ||
| 19 | ( | ||
| 20 | { preserve_existing => 1 }, | ||
| 21 | scalar => [ __PACKAGE__->common_method_maker_argument_names ] | ||
| 22 | ); | ||
| 23 | |||
| 24 | foreach my $type (__PACKAGE__->available_method_types) | ||
| 25 | { | ||
| 26 | __PACKAGE__->method_maker_type($type => 'set'); | ||
| 27 | } | ||
| 28 | |||
| 29 | sub type { 'set' } | ||
| 30 | |||
| 31 | *values = \&check_in; | ||
| 32 | |||
| 33 | sub parse_value { shift; shift->parse_set(@_) } | ||
| 34 | sub format_value { shift; shift->format_set(@_) } | ||
| 35 | |||
| 36 | sub should_inline_value | ||
| 37 | { | ||
| 38 | my($self, $db, $value) = @_; | ||
| 39 | no warnings 'uninitialized'; | ||
| 40 | return (($db->validate_set_keyword($value) && $db->should_inline_set_keyword($value)) || | ||
| 41 | ($db->keyword_function_calls && $value =~ /^\w+\(.*\)$/)) ? 1 : 0; | ||
| 42 | } | ||
| 43 | |||
| 44 | sub method_uses_formatted_key | ||
| 45 | { | ||
| 46 | my($self, $type) = @_; | ||
| 47 | return 1 if($type eq 'get' || $type eq 'set' || $type eq 'get_set'); | ||
| 48 | return 0; | ||
| 49 | } | ||
| 50 | |||
| 51 | sub init_with_dbi_column_info | ||
| 52 | { | ||
| 53 | my($self, $col_info) = @_; | ||
| 54 | |||
| 55 | $self->SUPER::init_with_dbi_column_info($col_info); | ||
| 56 | |||
| 57 | if(ref $col_info->{'RDBO_SET_VALUES'}) | ||
| 58 | { | ||
| 59 | $self->values($col_info->{'RDBO_SET_VALUES'}); | ||
| 60 | } | ||
| 61 | |||
| 62 | return; | ||
| 63 | } | ||
| 64 | |||
| 65 | 1; | ||
| 66 | |||
| 67 | __END__ |