Extending objects either from existing object or by loading externalplugins. How?


A

Andreas M.

If trying to extend an object via an object extender (as seen on
http://tinyurl.com/4txyvf). It takes two arguments:

obj(ect to extend) and prop(erty to extend with)

I want to remodel this function in a way, that prop can be either an
object I have already defined /or/ the filename of an external resource.
This is, because I may want to give the user flexibility as to which
plugin he wants to use. Let's say you got a database-communicator API
and want the user to be flexible whether to use SQLite3, MySQL or
PostgreSQL, etc. So, upon the users settings I will load the according
module. Even worse, the user may want to access different repositories
via different backends. So I need a generic database access API and a
flexible module system, that can change per object I instantiate from
the database API. Very dynamic.

A typical prop may be called:

MyApp.Services.Database.PostgreSQL or MyApp.Services.Database.SQLite3

However, not all of these are in the main application file. So I have a
subdirectory called "plugins", which has files named like the objects,
they represent:

MyApp.Services.Database.PostgreSQL.js
or
MyApp.Services.Database.SQLite3.js

Now I don't know how to solve this. Bascially I must have a way to find
out, whether the prop already exsits. If not, I test, whether the prop
is an object itself /or/ a string, defining an URI. If it is an URI, I
will use jslib's include() function, load that file. But how do I get it
to execute and deliver an object, like shown before?

Thx.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top