Sha256: 798c3d2f9b18768c35b22f6167e4c014eee829cba85f6592ef51dc2a8c4b1d67

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

var App = function () {
    var app_instance;

    app_instance = function () {
        var app = {},
            definitions = {},
            constants = {};

        app.define = function (constant, definition) {
            if (definitions[constant] !== undefined) {
                throw "Constant '" + constant + "' already defined."
            }
            if (typeof definition !== 'function') {
                throw "Definition has to be a function."
            }

            definitions[constant] = definition;
        };

        app.require = function (constant) {
            if (constants[constant] === undefined) {
                if (definitions[constant] === undefined) {
                    throw "Constant '" + constant + "' not defined."
                }
                constants[constant] = definitions[constant]();
            }

            return constants[constant];
        };

        return app;
    }

    return {
        Mediators: {},
        induce: function (scope) {
            scope.app = app_instance();
        }
    };
}();

App.induce(window);

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appjs-0.0.6 lib/assets/javascripts/app.js
appjs-0.0.5 lib/assets/javascripts/app.js
appjs-0.0.4 lib/assets/javascripts/app.js
appjs-0.0.2 lib/assets/javascripts/app.js