Sha256: 4506abb8001811f22aaf280546ca716cdc71dc9255dd0474dbcb5e4127358841
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
(function() { // Utility method to get and set objects that may or may not exist var objectifier = function(splits, create, context) { var result = context || window for(var i = 0, s; result && (s = splits[i]); i++) { result = (s in result ? result[s] : (create ? result[s] = {} : undefined)) } return result } // Creates an object if it doesn't already exist Object.extend('place', function(name, value, context) { var splits = name.split("."), s = splits.pop(), result = objectifier(splits, true, context) return result && s ? (result[s] = value) : undefined }) // Retrieves an object if not already present Object.extend('retrieve', function(name, create, context) { return objectifier(name.split('.'), create, context) }) // Checks to see if the object exists Object.extend('exists', function(name, context) { return Object.retrieve(name, false, context) !== undefined }) var klass = Class; // Redefine class Class = function(name, params, context) { // Find out if this is namespaced or the original method var namespaced = arguments.length > 1 // Add the class name to the param list if(namespaced) params.$name = name // Create and get the original class var original = new klass(namespaced ? params : name) // If namespaced, set class into namespace if(namespaced) Object.place(name, original, context) // Return this newly created class! return original } })()
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mootools-plus-0.2.0 | vendor/assets/javascripts/namespace.js |