Skip to content

Instantly share code, notes, and snippets.

@Kami
Created May 27, 2012 08:19
Show Gist options
  • Select an option

  • Save Kami/2802822 to your computer and use it in GitHub Desktop.

Select an option

Save Kami/2802822 to your computer and use it in GitHub Desktop.
Swiz - object definitions
var swiz = require('swiz');
var O = swiz.struct.Obj;
var F = swiz.struct.Field;
var defs = [
O('Server',
{
'fields': [
F('id', {'src': 'hash_id', 'desc': 'hash ID for the server', 'attribute': true}),
F('is_active', {'src': 'active', 'desc': 'is the server active?', 'coerceTo': 'boolean'}),
F('name', {'src' : 'get_name', 'desc' : 'name', 'attribute': true}),
F('agent_name'),
F('ipaddress' , {'src' : 'get_public_address'}),
F('public_ips', {'singular': 'ip', 'filterFrom': ['public'], 'coerceTo': 'array'}),
F('state', {'enumerated' : {inactive: 0, active: 1}, 'filterFrom': ['public']}),
F('opts', {'src': 'options'}),
F('data')
],
'plural': 'servers'
}),
O('ServerOpts',
{
'fields': [
F('option1', {'src': 'opt1'}),
F('option2', {'src': 'opt2'}),
F('option3', {'src': 'opt3'}),
],
'singular': 'serverOpts'
})
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment