The implementation style of Ember js

I have a situation were there are many Countries, many Groups of people, many Migrations(I consider this as a relationship class). I am using a worldController and timelineController to manage things. The worldController code is shown below. It happens that I feel I am wrong with the implementation seeing the weird way I am adding a group, looks like it will become a mess if I have more complex relationships :) I understand I am missing something core, please pardon me and plese explain what I am missing.

App.worldController = Em.Object.create({
    groups : [],
    addGroup : function(datum){
        var newGroup = App.Group.create({
            strength : datum.strength,
            hasOneMigration : App.Migration.create({
                year : datum.year,
                hasOneCountry : App.Country.create({
                    name : datum.to
                    })
                }),
            belongsToCountry : App.Country.create({
                name : datum.from
                })
            });
        this.groups.pushObject(newGroup);
        },
    loadGroups : function(DATA){
        for(var i=0; i < DATA.length; i++){
            this.addGroup(DATA[i]);
            }
        },
    init : function(){
        this.loadGroups(App.DATA);
        },
    currentYearBinding : 'App.timelineController.currentYear',
    activeGroups : function(){
        return this.groups.filter(function(group){
            if(group.getPath('hasOneMigration.year') <= Em.getPath('App.worldController.currentYear'))return true;
            });
        }.property('currentYear').cacheable()
    });

Thank you for your time.

This entry was posted in Codes & Scripts and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>