Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: Question about __PACKAGE__

by ikegami (Patriarch)
on Jan 22, 2010 at 07:39 UTC ( [id://818911]=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^6: Question about __PACKAGE__
by sman (Beadle) on Jan 22, 2010 at 22:00 UTC
    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.

Re^6: Question about __PACKAGE__
by sman (Beadle) on Jan 22, 2010 at 22:26 UTC
    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"?

        I have this assertion because seems the following line's function is to add additional base classes to the child class when child class is loaded. So I guess if I declared this inheritance relationship using 'extends' in the beginning, then I do not need to load it using this line. Am I right?
        _PACKAGE__->load_components( "InflateColumn::DateTime", "Core" );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://818911]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-23 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found