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
- . (void) useOptionsOrCreate(options, obj, owner_path) Used to either register yourself with the existing factory or to create a new factory.
Instance Method Summary
- # (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.
Class Method Details
.
(void)
useOptionsOrCreate(options, obj, owner_path)
Used to either register yourself with the existing factory or to create a new factory.
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