Skip to content

Instantly share code, notes, and snippets.

@deanlandolt
Created February 5, 2010 19:47
Show Gist options
  • Save deanlandolt/296150 to your computer and use it in GitHub Desktop.
Save deanlandolt/296150 to your computer and use it in GitHub Desktop.
// this fails with MethodNotAllowedError: SubModel is not allowed
var JSFile = require("store/js-file").JSFile;
var dataPath = (require("settings").dataFolder || "data") + "/";
var Package = require("package").Package;
var foo = Package("foo");
foo.bar = foo.Package("bar");
foo.bar.baz = foo.bar.SubModel("baz",
JSFile(dataPath + "store1.json"),
{
prototype: {
testMethod: function(){
return this.foo;
}
},
staticMethod: function(id) {
return this.get(id);
},
properties: {
foo: {type: "number"}
},
links: [
{rel: "foo", href: "{foo}"}
]
}
);
// this fails with MethodNotAllowedError: Package is not allowed
var Package = require("package").Package;
var foo = Package("foo");
foo.bar = foo.Package("bar");
foo.bar.baz = foo.bar.Package("baz");
// this works
var JSFile = require("store/js-file").JSFile;
var dataPath = (require("settings").dataFolder || "data") + "/";
var foo = Package("foo");
foo.baz = foo.SubModel("baz",
JSFile(dataPath + "store1.json"),
{
prototype: {
testMethod: function(){
return this.foo;
}
},
staticMethod: function(id) {
return this.get(id);
},
properties: {
foo: {type: "number"}
},
links: [
{rel: "foo", href: "{foo}"}
]
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment