Class: kb.Factory

Defined in: src/core/factory.coffee

Overview

Used to share the hierachy of constructors and create functions by path to allow for custom creation per Model attribute.

Examples:

Create an instance by path.

var factory = new kb.Factory();
factory.addPathMapping('bob.the.builder', kb.ViewModel);
view_model = factory.createForPath(new Backbone.Model({name: 'Bob'}), 'bob.the.builder'); // creates kb.ViewModel

Class Method Summary

Instance Method Summary

Class Method Details

. (void) useOptionsOrCreate(options, obj, owner_path)

Used to either register yourself with the existing factory or to create a new factory.

Parameters:

  • options ( Object ) please pass the options from your constructor to the register method. For example, constructor(model, options)
  • obj ( Instance ) the instance that will own or register with the store
  • owner_path ( String ) the path to the owning object for turning relative scoping of the factories to absolute paths.

Options Hash: (options):

  • factories ( Object ) a map of dot-deliminated paths; for example 'models.owner': kb.ViewModel to either constructors or create functions. Signature: 'some.path': function(object, options)

Constructor Details

# (void) constructor(parent_factory)

Instance Method Details

# (void) hasPath(path)

# (void) addPathMapping(path, create_info)

# (void) addPathMappings(factories, owner_path)

# (void) hasPathMappings(factories, owner_path)

# (void) creatorForPath(obj, path)

If possible, creates an observable for an object using a dot-deliminated path.

Examples:

Create an instance by path.

var factory = new kb.Factory();
factory.addPathMapping('bob.the.builder', kb.ViewModel);
view_model = factory.createForPath(new Backbone.Model({name: 'Bob'}), 'bob.the.builder'); // creates kb.ViewModel

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: