Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saksmt/object-oriented-extension
Protection without conventions
https://github.com/saksmt/object-oriented-extension
Last synced: about 2 months ago
JSON representation
Protection without conventions
- Host: GitHub
- URL: https://github.com/saksmt/object-oriented-extension
- Owner: saksmt
- Created: 2015-07-01T21:38:17.000Z (over 9 years ago)
- Default Branch: develop
- Last Pushed: 2015-07-01T21:38:49.000Z (over 9 years ago)
- Last Synced: 2024-01-27T16:20:20.912Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 105 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
object-oriented-extension
=========================Provides support for "protected" fields and methods without conventions. Also provides inherit functionality.
Usage
-----if (global.objectOrientedExtension) {
require("object-oriented-extension/ObjectOriented/JsExtension");
// or simply: 'global.include("ObjectOriented/JsExtension");', when using include-js package
}
var SomeClass = function (protectedData/*, some other arguments for constructor) {
protectedData.protectedField = 'some value';
protectedData.protectedMethod = function () {};
// Realization
};
SomeClass = SomeClass.injectProtected(); // <- that's it
var SomeChildClass = function (protectedData/*, ... */) {
SomeClass.call(this, someArgument); // <- Call parent constructor
// Realization
this.someMethod = function (someArg) {
SomeClass.someMethod.call(this, someArg); // <- Call parent method
};
};
SomeChildClass = SomeChildClass.extend(SomeClass); // <- simply like this (call of "injectProtected" is fully optional in that case)Almost useless bonus:
// In definition of some class...
this.someMethod = Function.abstractMethod();
this.someAnotherMethod = (function () {}).makeAbstract();