ContextLoader

ContextLoader

Same as FileLoader, but it will attach file to inject[fieldClass]. The exports will be lazy loaded, such as ctx.group.repository.

Constructor

new ContextLoader(options)

Parameters:
Name Type Description
options Object

options same as FileLoader

Properties
Name Type Description
fieldClass String

determine the field name of inject object.

Since:
  • 1.0.0
Source:

Extends

Methods

load() → {Object}

attach items to target object. Mapping the directory to properties. app/controller/group/repository.js => target.group.repository

Since:
  • 1.0.0
Overrides:
Source:

parse() → {Array}

Parse files from given directories, then return an items list, each item contains properties and exports.

For example, parse app/controller/group/repository.js

module.exports = app => {
  return class RepositoryController extends app.Controller {};
}

It returns a item

{
  properties: [ 'group', 'repository' ],
  exports: app => { ... },
}

Properties is an array that contains the directory of a filepath.

Exports depends on type, if exports is a function, it will be called. if initializer is specified, it will be called with exports for customizing.

Since:
  • 1.0.0
Overrides:
Source: