Engine#initializer()

initializer (initializer) public Inherited from Ember.Engine but overwritten in packages/ember-application/lib/system/engine.js:185 The goal of initializers should be to register dependencies and injections. This phase runs once. Because these initializers may load code, they are allowed to defer application readiness and advance it. If you need to access the container or store you should use an InstanceInitializer that will be run after all initializers and therefore after all code is load

Registry#injection()

injection (factoryName, property, injectionName) private Defined in packages/container/lib/registry.js:488 Defines injection rules. These rules are used to inject dependencies onto objects when they are instantiated. Two forms of injections are possible: Injecting one fullName on another fullName Injecting one fullName on a type Example: let registry = new Registry(); let container = registry.container(); registry.register('source:main', Source); registry.register('model:user', User); regi

Container#lookup()

lookup (fullName, options) Anyprivate Defined in packages/container/lib/container.js:71 Given a fullName return a corresponding instance. The default behaviour is for lookup to return a singleton instance. The singleton is scoped to the container, allowing multiple containers to all have their own locally scoped singletons. let registry = new Registry(); let container = registry.container(); registry.register('api:twitter', Twitter); let twitter = container.lookup('api:twitter'); twitter

Writing Helpers

Writing Helpers Helpers allow you to add additional functionality to your templates beyond what is included out-of-the-box in Ember. Helpers are most useful for transforming raw values from models and components into a format more appropriate for your users. For example, imagine we have an Invoice model that contains a totalDue attribute, which represents the total amount due for that invoice. Because we do not want our company to go out of business due to strange JavaScript rounding errors,

Engine.buildRegistry()

buildRegistry (namespace) Ember.Registryprivatestatic Inherited from Ember.Engine but overwritten in packages/ember-application/lib/system/engine.js:370 This creates a registry with the default Ember naming conventions. It also configures the registry: registered views are created every time they are looked up (they are not singletons) registered templates are not factories; the registered value is returned directly. the router receives the application as its namespace property all controll

DS.JSONSerializer#keyForRelationship()

keyForRelationship (key, typeClass, method) String Defined in addon/serializers/json.js:1458 keyForRelationship can be used to define a custom key when serializing and deserializing relationship properties. By default JSONSerializer does not provide an implementation of this method. Example app/serializers/post.js import DS from 'ember-data'; export default DS.JSONSerializer.extend({ keyForRelationship: function(key, relationship, method) { return 'rel_' + Ember.String.underscore

DS.JSONSerializer#attrs

attrs{Object} Defined in addon/serializers/json.js:111 The attrs object can be used to declare a simple mapping between property names on DS.Model records and payload keys in the serialized JSON object representing the record. An object with the property key can also be used to designate the attribute's key on the response payload. Example app/models/person.js import DS from 'ember-data'; export default DS.Model.extend({ firstName: DS.attr('string'), lastName: DS.attr('string'), occu

DS.EmbeddedRecordsMixin#serializeHasMany()

serializeHasMany (snapshot, json, relationship) Defined in addon/serializers/embedded-records-mixin.js:240 Serializes hasMany relationships when it is configured as embedded objects. This example of a post model has many comments: Post = DS.Model.extend({ title: DS.attr('string'), body: DS.attr('string'), comments: DS.hasMany('comment') }); Comment = DS.Model.extend({ body: DS.attr('string'), post: DS.belongsTo('post') }); Use a custom (type) serializer for the p

CoreObject#init()

initpublic Defined in packages/ember-runtime/lib/system/core_object.js:217 An overridable method called when objects are instantiated. By default, does nothing unless it is overridden during class definition. Example: App.Person = Ember.Object.extend({ init: function() { alert('Name is ' + this.get('name')); } }); var steve = App.Person.create({ name: "Steve" }); // alerts 'Name is Steve'. NOTE: If you do override init for a framework class like Ember.View, be sure to call this

Registry#optionsForType()

optionsForType (type, options) private Defined in packages/container/lib/registry.js:356 Allow registering options for all factories of a type. let registry = new Registry(); let container = registry.container(); // if all of type `connection` must not be singletons registry.optionsForType('connection', { singleton: false }); registry.register('connection:twitter', TwitterConnection); registry.register('connection:facebook', FacebookConnection); let twitter = container.lookup('connection