stage.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. // Copyright 2012 United States Government, as represented by the Secretary of Defense, Under
  3. // Secretary of Defense (Personnel & Readiness).
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  6. // in compliance with the License. You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software distributed under the License
  11. // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  12. // or implied. See the License for the specific language governing permissions and limitations under
  13. // the License.
  14. /// @module vwf/model/stage
  15. /// @requires vwf/model
  16. define( [ "module", "vwf/model" ], function( module, model ) {
  17. return model.load( module, {
  18. // == Module Definition ====================================================================
  19. modelize: function( model, model_api ) {
  20. this.model = model;
  21. // Suppress functions that aren't implemented in the stage to the right.
  22. Object.keys( model_api ).forEach( function( modelFunctionName ) {
  23. if ( ! model[modelFunctionName] ) {
  24. this[modelFunctionName] = undefined;
  25. }
  26. }, this );
  27. },
  28. }, function( modelFunctionName ) {
  29. // == Model API ============================================================================
  30. return function() {
  31. return this.model[modelFunctionName] && this.model[modelFunctionName].apply( this.model, arguments );
  32. };
  33. }, function( kernelFunctionName ) {
  34. // == Kernel API ===========================================================================
  35. return function() {
  36. return this.kernel[kernelFunctionName].apply( this.kernel, arguments );
  37. };
  38. } );
  39. } );