note
domm
<b>My Problem:</b>
I've got several classes, looking a little bit like this:
<pre>
App
|
App::Basic
/ \
App::Basic::Special1 App::Basic::Special2
| |
| |
| My::App |
| / \ |
My::App::Special1 My::App::Special2
</pre>
Note that My::App <b>doesn't</b> inherit from App. And note that there are My::OtherApp, Your::App too, looking like My::App and inheriting from App::*
<p>
Each of this Classes contains some config values as Class Data.
<p>
I want to be able to fetch all those config values, merge them and do something with the result.
<p>
E.g.: Say, each class contains an array called @order and a hash called %lables.<br>
@order contains some fields to be displayed<br>
%lables contains the name of those fields as keys and a "human readable" name as values.<br>
<code>
@order=(field1,field2,field2,..);
%lable={
field1=&gt;"Name of Field 1",
field2=&gt;"Name of Field 2",
..
);
</code>
<p>
Each Class now defines some of those values. Some Classes append new values to @order and %lables, some overwrite data in %lables.
<p>
There are some basic fields (used everywhere in the app) defined in App::Basic. Each App::Basic::Special1/2 adds some fields unique to this special case.
<p>
Now, My::App changes some field lables (e.g. use another language). My::App::Special1 may add even more fields that are only needed in My::App (there might be a My::OtherApp::Special1 that inherits from App::Basic::Special1 and doesn't use this fields)
<p>
Then I call dispatch_to_all('get_fields') which fetches all those @field arrays, massage the returned array of all return values to fit my needs, and voila: I get the array of fields used by this Class, without having to specify the "Basic" fields in all Subclasses (which would result in a lot of typing and and even bigger lot of problems should I need to change a App::Basic config value)
<p>
This was/is my problem, and that's why I wrote Class::DispatchToAll, which seems the best way to solve this problem to me. But if you now another way, please let me know...
<code>
--
#!/usr/bin/perl
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}
</code>
180852
180906