Extending model objects


Sometimes it can be helpful to add completely new objects to Skipper project to store various data from your company environment. For this, Skipper offers feature called universal-objects.

Universal object behaves like any other Skipper object, it can be placed in project tree, stored in modules, shared between projects and have custom ORM properties. Each universal object has it’s own name, type and class. Thanks to this, you can configure several types of universal objects used for different task in your company environment.

<universal-object name="test-object" type="test-type" class="test-class">
  <orm-attributes>
    <attribute name="attribute">value</attribute>
  </orm-attributes>
</universal-object>

Why is this feature so cool?

It’s because you can use it to anything you need. This object is not exported to schema files. All these object definitions remain in project XML files, where you can proceed it by your external tools.

For example in situation when you need to store information about deploy process, it is pretty simple to create new universal-object with class ‘deploy’, add some configuration directives for example path, remote url etc.

<universal-object class='deploy' name='deploy-to-staging'>
  <orm-attributes>
   <attribute name='server'>192.168.0.111</attribute>
   <attribute name='path'>/upload/latest-version</attribute>
  </orm-attributes>
</universal-object>

Now when your project contains universal-object with these values, you can made your own script which uses xpath to search for specific values:

#simplified example only
xml.open(project.xml);
var server = xml.xpath("//universal-object[@class='deploy' and name='deploy-to-staging']/orm-attributes/attribute[@name='server']");

connection.open(server);
...

As you can see, the possibilities are endless. You can manage your CI with Skipper, you can hold anything you need directly with your model and use it later with your own scripts or applications.

Configuring universal objects

You can add several orm-attributes to universal object like to any other Skipper object.

<attribute-types>
  <struct name="UniversalObject">
    <attribute name="attribute" type="string" />
  </struct>
</attribute-types>

How to enable Universal objects in your project

Universal objects are hidden by default for any project and ORM. It’s because Universal object is advanced feature and used only by more complex projects and use cases.

To enable Universal objects for your project or ORM, simply add following <setting> clausule to <application-settings> element.

<application-settings>
  <setting name="Model/UniversalObject/Allow" value="true"/>
</application-settings>