ember-abstract-macro
v1.4.0
Published
Collection of Computed Property macro for make properties & methods as abstract
Downloads
3
Readme
ember-abstract-macro
Collection of Computed Property macro for make properties & methods as abstract
Usage
For methods:
import { AbstractMethod } from 'ember-abstract-macro';
const ObjectWithAbstractMethod = Ember.Object.extend({
mustBeOverridden: AbstractMethod('my-module-name.mustBeOverridden()')
});
const foo = ObjectWithAbstractMethod.create();
foo.mustBeOverridden(); // raise Assertion 'Method my-module-name.mustBeOverridden() must be overridden'
const bar = ObjectWithAbstractMethod.create({
mustBeOverridden() { return 42; }
});
foo.mustBeOverridden(); // return 42
For properties:
import { AbstractProperty } from 'ember-abstract-macro';
const ObjectWithAbstractProperty = Ember.Object.extend({
mustBeOverridden: AbstractProperty( 'my-module-name' )
});
const foo = ObjectWithAbstractProperty.create();
foo.get('mustBeOverridden'); // raise Assertion 'Class my-module-name, property mustBeOverridden must be overridden'
const foo = ObjectWithAbstractProperty.create({
mustBeOverridden: 42
});
foo.get('mustBeOverridden'); // return 42
As decorator:
import { property as abstract } from 'ember-abstract-macro/property';
class ClassWithAbstractProperty extends Ember.Object {
@abstract( 'my-module-name' ) mustBeOverridden() {}
}
const foo = ClassWithAbstractProperty.create();
foo.get('mustBeOverridden'); // raise Assertion 'Class my-module-name, property mustBeOverridden must be overridden'
class ObjectWithAbstractProperty extends Ember.Object {
@abstract('my-module-name') mustBeOverridden() {}
}
const foo = ObjectWithAbstractProperty.create({
mustBeOverridden: 42
});
foo.get('mustBeOverridden') // return 42
Installation
ember install ember-abstract-macro
Addon Maintenance
Installation
git clone https://github.com/shamcode/ember-abstract-macro.git
cd ember-abstract-macro
yarn install
Linting
yarn lint:js
yarn lint:js --fix
Running tests
ember test
– Runs the test suite on the current Ember versionember test --server
– Runs the test suite in "watch mode"ember try:each
– Runs the test suite against multiple Ember versions
Running the dummy application
ember serve
- Visit the dummy application at http://localhost:4200.
For more information on using ember-cli, visit https://ember-cli.com/.
License
This project is licensed under the MIT License.