On 4/2/07, Ovid <[EMAIL PROTECTED]> wrote:
> I didn't see it in the docs, but is there anything akin to 'mutator'
> metadata which would let me do something like the following?
>
>   foreach my $method ( $class->mutators ) {
>     $self->make_override( $method );
>   }
>
> The 'mutators' would return all 'set_*' type methods along with the
> 'update', 'delete', etc. methods.

You can get a list of column mutator methods:

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata.pm#column_mutator_method_names

You will have to grep { defined } because there'll be undef items for
columns with no mutator methods.  It's just a convenience method
anyway.  Given:

    $meta = MyClass->meta;

Here are a few increasingly verbose, equivalent Ways To Do It:

    @mutators = grep { defined } $meta->column_mutator_method_names;

    @mutators =
      grep { defined } map { $_->mutator_method_name } $meta->columns;

    @mutators =
      grep { defined }
      map { $_->method_name('set') || $_->method_name('get_set') }
      $meta->columns;

Note that the purpose of these calls is slightly different than your
(apparent) purpose.  $column->mutator_method_name returns "a method"
that can be used to mutate the column.  If a column has both a "set"
and a "get_set" method, then there are two such methods.  For an
exhaustive list of "all methods" that can be used to mutate the
column, modify the last example to be:

    @mutators =
      grep { defined }
      map { $_->method_name('set'), $_->method_name('get_set') }
      $meta->columns;

Anyway, column mutator methods just change the value of an attribute
of an in-memory object.  Nothing gets written to the database until
you save(), insert(), update(), or delete().  (That's the full list of
object methods that change the database.)

-John

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to