File tree Expand file tree Collapse file tree 3 files changed +46
-2
lines changed
Expand file tree Collapse file tree 3 files changed +46
-2
lines changed Original file line number Diff line number Diff line change 1+ <p align =" center " >
2+ <a href =" https://www.typisch-touristik.de " >
3+ <img alt="Typisch Touristik" src="https://s3.eu-central-1.amazonaws.com/typischtouristik/logo_typisch-touristik_1200x443.png" width="200">
4+ </a >
5+ </p >
6+
7+ <p align =" center " >
8+ Mixins (horizontal inheritance) for sails models.
9+ </p >
10+
11+ <p align =" center " >
12+ <a href =" https://travis-ci.org/TypischTouristik/sails-hook-mixins " target =" _blank " ><img alt =" Travis Status " src =" https://travis-ci.org/TypischTouristik/sails-hook-mixins.svg " ></a >
13+ <a href =" https://david-dm.org/TypischTouristik/sails-hook-mixins " target =" _blank " ><img alt =" Dependency Status " src =" https://david-dm.org/TypischTouristik/sails-hook-mixins.svg " ></a >
14+ <a href =" https://github.com/TypischTouristik/sails-hook-mixins/releases " ><img alt =" Version Status " src =" https://badge.fury.io/gh/TypischTouristik%2Fsails-hook-mixins.svg " ></a >
15+ </p >
16+
17+ ---
Original file line number Diff line number Diff line change 1+ var deepExtend = require ( 'deep-extend' ) ;
2+
3+ module . exports = function ( sails ) {
4+
5+ return {
6+ initialize : function ( done ) {
7+ sails . after ( [ 'hook:moduleloader:loaded' ] , function ( ) {
8+ _ . each ( sails . models , function ( model ) {
9+ // bind model additional attributes on concrete models and left derived model build from associations
10+ if ( ! model . globalId || ! model . mixins ) {
11+ return ;
12+ }
13+
14+ _ . each ( model . mixins , function ( name ) {
15+ var mixin = require ( process . cwd ( ) + '/api/mixins/' + name ) ;
16+ deepExtend ( model , mixin ) ;
17+ } ) ;
18+ } ) ;
19+
20+ done ( ) ;
21+ } ) ;
22+ }
23+ } ;
24+
25+ } ;
Original file line number Diff line number Diff line change 1313 "sails" : {
1414 "isHook" : true
1515 },
16- "dependencies" : {},
16+ "dependencies" : {
17+ "deep-extend" : " ^0.4.1"
18+ },
1719 "repository" : {
1820 "type" : " git" ,
1921 "url" : " git://github.com/TypischTouristik/sails-hook-mixins.git"
2325 "mocha" : " ^3.1.2" ,
2426 "sails" : " ^0.12.8"
2527 }
26- }
28+ }
You can’t perform that action at this time.
0 commit comments