Create new property type "fn" #116

Closed
Marak opened this Issue Sep 2, 2012 · 3 comments

Comments

Projects
None yet
1 participant
Contributor

Marak commented Sep 2, 2012

There should be a new type of property that can be set on resources called "fn".

This property would act as a helper method for adding what we currently call "remote" methods to resources.

Ex:

var Author = resourceful.define('author');
Author.string('name', { default: "bobby", required: true });
Author.method('hello', function(){
  return 'hello';
}, optionalSchema);

Would be equivalent to the old api of:

var Author = resourceful.define('author');
Author.string('name', { default: "bobby", required: true });
Author.hello = function () {
  return 'hello';
};
Author.remote = true;

This is beneficial for a few reasons:

  • more declarative control over specifying non-core arbitrary functions
  • as per #115, resource types can be introspected, and a function would be a type
  • ability to enforce JSON-schema on function's arguments in any interface
  • ability to introspect method signatures ( via schema ) generating documentation
Contributor

Marak commented Sep 3, 2012

The delta to add this feature is small, I've got a branch working locally now.

Polishing off the API and examples, will push the new branch in a few days.

Marak added a commit that referenced this issue Sep 3, 2012

Contributor

Marak commented May 27, 2013

invalid

@Marak Marak closed this May 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment