@@ -725,11 +725,6 @@ function createClass(classId) {
725
725
'return function id () { return __body.call(this) };'
726
726
) ( body ) ;
727
727
728
- // classInfo
729
- if ( $metamodel . inheritFrom ( classId , '_Component' ) ) {
730
- config . classInfo = classId + 'Info' ;
731
- }
732
-
733
728
// create link to db
734
729
$db . store [ classId ] [ config . _id ] = config ;
735
730
@@ -758,19 +753,19 @@ function createClass(classId) {
758
753
}
759
754
760
755
/**
761
- * @method addId
756
+ * @method addIdClass
762
757
* @param {Function } Class a class
763
758
* @param {String } classId name of the class
764
759
* @private
765
760
* @description Add an id method to a class that will return its id
766
761
*/
767
- function addId ( Class , classId ) {
762
+ function addIdClass ( Class , classId ) {
768
763
var body = function body ( ) {
769
764
return classId ;
770
765
} ;
771
766
Class . id = new Function (
772
767
'__body' ,
773
- 'return function id (prop, val ) { return __body.call(this, prop, val ) };'
768
+ 'return function id () { return __body.call(this) };'
774
769
) ( body ) ;
775
770
}
776
771
@@ -1461,15 +1456,15 @@ function addStructure(path, name, model, id) {
1461
1456
* @param {Function } Class Class
1462
1457
* @param {String } classId name of the class
1463
1458
* @private
1464
- * @description * Add methods to a component.
1459
+ * @description Add methods to a component.
1465
1460
* The call to these methods will invoke the workflow in order to check that inpouts / outputs are compliant with the model.
1466
1461
*/
1467
1462
function addMethods ( model , Class , classId ) {
1468
1463
var methods = getMethods ( model ) ;
1469
1464
1470
1465
methods . forEach ( function method ( methodName ) {
1471
1466
var paramsName = getParamNames ( classId , methodName ) ;
1472
- var params = paramsName . join ( ',' ) ;
1467
+ var params = paramsName . join ( ', ' ) ;
1473
1468
var paramsWithContext = '' ;
1474
1469
1475
1470
var body = function body ( ) {
@@ -1506,7 +1501,7 @@ function addMethods(model, Class, classId) {
1506
1501
1507
1502
if ( params ) {
1508
1503
paramsName . unshift ( 'context' ) ;
1509
- paramsWithContext = paramsName . join ( '' ) ;
1504
+ paramsWithContext = paramsName . join ( ', ' ) ;
1510
1505
1511
1506
Class . prototype [ methodName ] = new Function (
1512
1507
'__body' ,
@@ -1560,7 +1555,7 @@ function addEvents(model, Class, classId) {
1560
1555
var events = getEvents ( model ) ;
1561
1556
events . forEach ( function event ( methodName ) {
1562
1557
var paramsName = getParamNames ( classId , methodName ) ;
1563
- var params = paramsName . join ( ',' ) ;
1558
+ var params = paramsName . join ( ', ' ) ;
1564
1559
1565
1560
var body = function body ( ) {
1566
1561
var systems = [ ] ;
@@ -1635,7 +1630,7 @@ function addEvents(model, Class, classId) {
1635
1630
* @description Add a on method to a component to add behaviors to the component
1636
1631
*/
1637
1632
function addOn ( Class , classId ) {
1638
- var body = function body ( state , handler , useCoreAPI , isCore , context ) {
1633
+ var body = function body ( state , action , useCoreAPI , isCore , context ) {
1639
1634
var behaviorId = '' ;
1640
1635
var currentState = '' ;
1641
1636
@@ -1659,11 +1654,11 @@ function addOn(Class, classId) {
1659
1654
) {
1660
1655
$log . behaviorNotUnique ( classId , state ) ;
1661
1656
} else {
1662
- if ( $workflow . validParamNumbers ( classId , state , handler ) ) {
1657
+ if ( $workflow . validParamNumbers ( classId , state , action ) ) {
1663
1658
behaviorId = $behavior . add (
1664
1659
this . id ( ) ,
1665
1660
state ,
1666
- handler ,
1661
+ action ,
1667
1662
useCoreAPI ,
1668
1663
isCore ,
1669
1664
context
@@ -1689,7 +1684,7 @@ function addOn(Class, classId) {
1689
1684
} ;
1690
1685
Class . prototype . on = new Function (
1691
1686
'__body' ,
1692
- 'return function on (state, handler , useCoreAPI, isCore, context) { return __body.call(this, state, handler , useCoreAPI, isCore, context) };'
1687
+ 'return function on (state, action , useCoreAPI, isCore, context) { return __body.call(this, state, action , useCoreAPI, isCore, context) };'
1693
1688
) ( body ) ;
1694
1689
}
1695
1690
@@ -1701,7 +1696,7 @@ function addOn(Class, classId) {
1701
1696
* @description Add a on method to a class component to add behaviors to the class
1702
1697
*/
1703
1698
function addOnClass ( Class , classId ) {
1704
- var body = function body ( state , handler , useCoreAPI , isCore , context ) {
1699
+ var body = function body ( state , action , useCoreAPI , isCore , context ) {
1705
1700
var behaviorId = '' ;
1706
1701
var currentState = '' ;
1707
1702
@@ -1725,11 +1720,11 @@ function addOnClass(Class, classId) {
1725
1720
) {
1726
1721
$log . behaviorNotUnique ( classId , state ) ;
1727
1722
} else {
1728
- if ( $workflow . validParamNumbers ( classId , state , handler ) ) {
1723
+ if ( $workflow . validParamNumbers ( classId , state , action ) ) {
1729
1724
behaviorId = $behavior . add (
1730
1725
this . id ( ) ,
1731
1726
state ,
1732
- handler ,
1727
+ action ,
1733
1728
useCoreAPI ,
1734
1729
isCore ,
1735
1730
context
@@ -1755,7 +1750,7 @@ function addOnClass(Class, classId) {
1755
1750
} ;
1756
1751
Class . on = new Function (
1757
1752
'__body' ,
1758
- 'return function on (state, handler , useCoreAPI, isCore, context) { return __body.call(this, state, handler , useCoreAPI, isCore, context) };'
1753
+ 'return function on (state, action , useCoreAPI, isCore, context) { return __body.call(this, state, action , useCoreAPI, isCore, context) };'
1759
1754
) ( body ) ;
1760
1755
}
1761
1756
@@ -1836,6 +1831,36 @@ function addDestroyClass(Class) {
1836
1831
) ( body ) ;
1837
1832
}
1838
1833
1834
+ /**
1835
+ * @method addRequireClass
1836
+ * @param {Object } Class Class
1837
+ * @private
1838
+ * @description Require a component
1839
+ */
1840
+ function addRequireClass ( Class ) {
1841
+ var body = function body ( id ) {
1842
+ return exports . get ( id ) ;
1843
+ } ;
1844
+ Class . require = new Function (
1845
+ '__body' ,
1846
+ 'return function require (id) { return __body.call(this, id) };'
1847
+ ) ( body ) ;
1848
+ }
1849
+
1850
+ /**
1851
+ * @method addInitClass
1852
+ * @param {Object } Class Class
1853
+ * @private
1854
+ * @description Init a class
1855
+ */
1856
+ function addInitClass ( Class ) {
1857
+ var body = function body ( ) { } ;
1858
+ Class . init = new Function (
1859
+ '__body' ,
1860
+ 'return function init (conf) { return __body.call(this, conf) };'
1861
+ ) ( body ) ;
1862
+ }
1863
+
1839
1864
/**
1840
1865
* @method addClassInfoClass
1841
1866
* @param {Object } Class Class
@@ -1875,7 +1900,7 @@ function factory(config) {
1875
1900
1876
1901
store [ classId ] = Class ;
1877
1902
1878
- addId ( Class , classId ) ;
1903
+ addIdClass ( Class , classId ) ;
1879
1904
1880
1905
addProperties ( config . model , Class , classId ) ;
1881
1906
addMethods ( config . model , Class , classId ) ;
@@ -1885,8 +1910,11 @@ function factory(config) {
1885
1910
// inherit from _Component
1886
1911
if ( $metamodel . inheritFrom ( classId , '_Component' ) ) {
1887
1912
addOn ( Class , classId ) ;
1913
+
1888
1914
addOnClass ( Class , classId ) ;
1889
1915
addOffClass ( Class , classId ) ;
1916
+ addRequireClass ( Class ) ;
1917
+ addInitClass ( Class ) ;
1890
1918
addDestroyClass ( Class ) ;
1891
1919
addClassInfoClass ( Class ) ;
1892
1920
}
0 commit comments