examples/todos/js/backbonefire.js
function(model, options) {
        Backbone.Model.apply(this, arguments);
        var defaults = _.result(this, 'defaults');

        // Apply defaults only after first sync.
        this.once('sync', function() {
          this.set(_.defaults(this.toJSON(), defaults));
        });

        this.autoSync = Backbone.Firebase._determineAutoSync(this, options);

        switch (typeof this.url) {
        case 'string':
          this.firebase = Backbone.Firebase._determineRef(this.url);
          break;
        case 'function':
          this.firebase = Backbone.Firebase._determineRef(this.url());
          break;
        case 'object':
          this.firebase = Backbone.Firebase._determineRef(this.url);
          break;
        default:
          Backbone.Firebase._throwError('url parameter required');
        }

        if(!this.autoSync) {
          OnceModel.apply(this, arguments);
          _.extend(this, OnceModel.protoype);
        } else {
          _.extend(this, SyncModel.protoype);
          SyncModel.apply(this, arguments);
        }

      }
function(model, options) {
        Backbone.Model.apply(this, arguments);
        var defaults = _.result(this, 'defaults');

        // Apply defaults only after first sync.
        this.once('sync', function() {
          this.set(_.defaults(this.toJSON(), defaults));
        });

        this.autoSync = Backbone.Firebase._determineAutoSync(this, options);

        switch (typeof this.url) {
        case 'string':
          this.firebase = Backbone.Firebase._determineRef(this.url);
          break;
        case 'function':
          this.firebase = Backbone.Firebase._determineRef(this.url());
          break;
        case 'object':
          this.firebase = Backbone.Firebase._determineRef(this.url);
          break;
        default:
          Backbone.Firebase._throwError('url parameter required');
        }

        if(!this.autoSync) {
          OnceModel.apply(this, arguments);
          _.extend(this, OnceModel.protoype);
        } else {
          _.extend(this, SyncModel.protoype);
          SyncModel.apply(this, arguments);
        }

      }
function ( model , options ) { Backbone . Model . apply ( this , arguments ) ; var defaults = _ . result ( this , 'defaults' ) ; // Apply defaults only after first sync. this . once ( 'sync' , function ( ) { this . set ( _ . defaults ( this . toJSON ( ) , defaults ) ) ; } ) ; this . autoSync = Backbone . Firebase . _determineAutoSync ( this , options ) ; switch ( typeof this . url ) { case 'string' : this . firebase = Backbone . Firebase . _determineRef ( this . url ) ; break ; case 'function' : this . firebase = Backbone . Firebase . _determineRef ( this . url ( ) ) ; break ; case 'object' : this . firebase = Backbone . Firebase . _determineRef ( this . url ) ; break ; default : Backbone . Firebase . _throwError ( 'url parameter required' ) ; } if ( ! this . autoSync ) { OnceModel . apply ( this , arguments ) ; _ . extend ( this , OnceModel . protoype ) ; } else { _ . extend ( this , SyncModel . protoype ) ; SyncModel . apply ( this , arguments ) ; } }
Determine whether the realtime or once methods apply
Determine whether the realtime or once methods apply