<?xml version="1.0" encoding="windows-1252"?>
<node id="867968" title="Re: Conditional inheritance strategy" created="2010-10-28 05:52:57" updated="2010-10-28 05:52:57">
<type id="11">
note</type>
<author id="742738">
happy.barney</author>
<data>
<field name="doctext">
few notes:&lt;br&gt;
use dispatch map
&lt;code&gt;

our $dispatch_map = {
  xml =&gt; 'My::XML',
  json =&gt; 'My::JSON',
};

sub new {
 ...

  die unless exists $dispatch_map-&gt;{$args{source}};

  my $class = $dispatch_map-&gt;{$args{source}}
  Module::Load::load ($class);

  $self-&gt;{engine} = $class; # or $class-&gt;new ($self);
}
&lt;/code&gt;

you can call foreign methods ...
&lt;code&gt;
  $self-&gt;My::JSON::_init;

  # or

  my $method = $self-&gt;{engine} . '::_init';
  $self-&gt;$method;

&lt;/code&gt;</field>
<field name="root_node">
867690</field>
<field name="parent_node">
867690</field>
</data>
</node>
