Comparing version 1.0.0 to 1.1.0
@@ -58,2 +58,21 @@ # moddle Descriptor | ||
### Extending existing Types | ||
Some meta-models require it to plug-in new properties that to certain existing model elements. This can be acomplished using the `extends` field. Consider the following type definition: | ||
```json | ||
{ | ||
"name": "BetterRoot", | ||
"extends": [ "Root" ], | ||
"properties": [ | ||
{ "name": "id", "type": "Number" } | ||
] | ||
} | ||
``` | ||
With this model definition, every instance of `Root` will automatically have another property `BetterRoot#id` added. At the same time, instances of root will be instances of `BetterRoot`, too. | ||
This extension is _implicit_ when compared to [inheritance](#inheritance). In the inheritance case one would need to instantiate `BetterRoot`, to actually get the new property `id`. Extending allows us to simply instantiate `Root` with the additional property defined for it. | ||
## Property Definition | ||
@@ -60,0 +79,0 @@ |
@@ -139,3 +139,6 @@ 'use strict'; | ||
var element = { | ||
$type: name | ||
$type: name, | ||
$instanceOf: function(type) { | ||
return type === this.$type; | ||
} | ||
}; | ||
@@ -142,0 +145,0 @@ |
{ | ||
"name": "moddle", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A library for importing meta-model based file formats into JS", | ||
@@ -9,3 +9,6 @@ "directories": { | ||
"scripts": { | ||
"test": "grunt test" | ||
"all": "run-s lint test", | ||
"lint": "eslint .", | ||
"dev": "npm test -- --watch", | ||
"test": "mocha -r ./test/expect --reporter=spec test/**/*.js" | ||
}, | ||
@@ -36,11 +39,7 @@ "repository": { | ||
"devDependencies": { | ||
"chai": "^1.10.0", | ||
"grunt": "~0.4.2", | ||
"grunt-contrib-connect": "~0.6.0", | ||
"grunt-contrib-jshint": "~0.7.2", | ||
"grunt-contrib-watch": "~0.5.0", | ||
"grunt-mocha-test": "^0.12.4", | ||
"grunt-release": "^0.7.0", | ||
"load-grunt-tasks": "~0.3.0", | ||
"mocha": "^2.1.0" | ||
"chai": "^4.1.2", | ||
"eslint": "^4.11.0", | ||
"eslint-plugin-mocha": "^4.11.0", | ||
"mocha": "^4.0.1", | ||
"npm-run-all": "^4.1.2" | ||
}, | ||
@@ -47,0 +46,0 @@ "dependencies": { |
@@ -116,3 +116,3 @@ 'use strict'; | ||
var customProperty = model.create('c:Property', { key: "foo", value: "bar" }); | ||
var customProperty = model.create('c:Property', { key: 'foo', value: 'bar' }); | ||
@@ -157,3 +157,3 @@ // when | ||
expect(descriptor.propertiesByName['id'].type).to.eql('Integer'); | ||
}) | ||
}); | ||
@@ -160,0 +160,0 @@ }); |
@@ -159,2 +159,4 @@ 'use strict'; | ||
}); | ||
expect(anyInstance.$instanceOf('other:Foo')).to.be.true; | ||
}); | ||
@@ -161,0 +163,0 @@ |
@@ -59,3 +59,3 @@ 'use strict'; | ||
xit('should inherit properties'); | ||
it.skip('should inherit properties'); | ||
@@ -142,3 +142,3 @@ }); | ||
xit('should set collection properties in constructor'); | ||
it.skip('should set collection properties in constructor'); | ||
@@ -145,0 +145,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63137
5
34
1746