Home Reference Source Repository
public class | source

OlapicEntity

This is the abstract class that all the entities will extend and implement.

Constructor Summary

Public Constructor
public

The class constructor that will receive all the entity information.

Member Summary

Public Members
public

An alias/name for the entity, for debug purposes.

public

The entity information.

public get

A quick shortcut for the entities so they can access their own entities handler.

Method Summary

Public Methods
public

get(path: string): *

Access the entity data using a path-like format.

public

A utility method that returns the entity name/alias.

Public Constructors

public constructor(data: Object) source

The class constructor that will receive all the entity information. On an implementation, this object will be instantiated from the entityFromJSON handler method, which will take care of parsing raw data before creating the entity.

All the information sent with the data argument will later be accessible using the get method.

Params:

NameTypeAttributeDescription
data Object

The entity information.

Public Members

public alias: String source

An alias/name for the entity, for debug purposes.

public data: Object source

The entity information.

public get handler: OlapicEntitiesHandler: * source

A quick shortcut for the entities so they can access their own entities handler. For example, the OlapicMediaEntity will get the OlapicMediaHandler.

Return:

OlapicEntitiesHandler

The handler class for that specific entity.

Public Methods

public get(path: string): * source

Access the entity data using a path-like format.

Params:

NameTypeAttributeDescription
path string

The path-like name for the property.

Return:

*

The value of the wanted property.

Example:

let entity = new OlapicEntity({
    name: 'MyEntity',
    props: {
        olapic: 'rocks',
    },
});
// This will log 'MyEntity'
console.log(entity.get('name'));
// This will log 'rocks'
console.log(entity.get('props/olapic'));

public toString(): string source

A utility method that returns the entity name/alias.

Return:

string

The class alias.