in reply to Re^3: Question about __PACKAGE__
in thread Question about __PACKAGE__

I found the corresponding classes that these three class methods belong to:

DBIx::Class::ResultSourceProxy::Table
table()
add_columns()

Class::C3::Componentised
load_components()

And I also know Class::C3::Componentised is the parent class of DBIx::Class that is the parent of Item, so this makes sense. But I don't know the relationship between DBIx::Class::ResultSourceProxy::Table and DBIx::Class.

Any idea?

Replies are listed 'Best First'.
Re^5: Question about __PACKAGE__
by ikegami (Patriarch) on Jan 22, 2010 at 07:39 UTC

    Taking an educated guess with grep is indeed the easiest path sometimes.

    load_components loads modules and adds them as base class (kinda like use base does).

    load_components('Core') loads DBIx::Class::Core and makes DBIx::Class::Core a base class of your class.

    DBIx::Class::Core similarly uses load_components loads a number of modules (including DBIx::Class::ResultSourceProxy::Table) and adds them to its list of base classes.

    package Result::Item; use strict; use warnings; use base 'DBIx::Class'; __PACKAGE__->load_components( "InflateColumn::DateTime", "Core" ); print "Parents of Result::Item:\n"; print "$_\n" for @Result::Item::ISA; print "\n"; print "Parents of DBIx::Class::Core:\n"; print "$_\n" for @DBIx::Class::Core::ISA;
    Parents of Result::Item: DBIx::Class::InflateColumn::DateTime DBIx::Class::Core DBIx::Class Parents of DBIx::Class::Core: DBIx::Class::Relationship DBIx::Class::InflateColumn DBIx::Class::PK::Auto DBIx::Class::PK DBIx::Class::Row DBIx::Class::ResultSourceProxy::Table DBIx::Class
      Thanks for your reply.

        But why my result is a bit different from yours?

        The code I posted couldn't possibly give the result you got.I presume you got different results because you ran different code.

      I got your point. I guess I can change class Item to inherit from DBIx::Class::Core instead of DBIx::Class and comment out this line :
      __PACKAGE__->load_components( "InflateColumn::DateTime", "Core" );
      Am I right?

        I can change class Item to inherit from DBIx::Class::Core instead of DBIx::Class

        Why would you do that?

        In your previous post, you showed that you weren't inheriting from DBIx::Class, so why do you say "instead"?