Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add traits plugin #374

Closed
ClickerMonkey opened this issue Feb 14, 2017 · 0 comments
Closed

Add traits plugin #374

ClickerMonkey opened this issue Feb 14, 2017 · 0 comments
Assignees
Milestone

Comments

@ClickerMonkey
Copy link
Member

Adds an array of objects to the prototype of the given Model. If a function is given it is invoked with the Model and options expecting an object to be returned.

Example:

function TraitGenerator( model, options ) {
  return {
    traitFunction: function() {
      // this = model instance
    }
  }
}

var MyTrait = {
  sharedFunction: function() {
    this.set({done: true, done_at: Rekord.now()});
    return this.save();
  }
};

var Task = Rekord({
  name: 'task',
  fields: ['name', 'done', 'done_at'],
  traits: [MyTrait, TraitGenerator]
});
@ClickerMonkey ClickerMonkey self-assigned this Feb 14, 2017
@ClickerMonkey ClickerMonkey modified the milestone: 1.6.0 Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant