Last active
August 29, 2015 13:56
-
-
Save robrichard/9261001 to your computer and use it in GitHub Desktop.
Before and after browserify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var SoaModel = require('@bunsen/models/SoaModel'), | |
Shipment = SoaModel.extend(); | |
module.exports = bunsen.Shipment = Shipment; | |
var Backbone = require('Backbone'), | |
_ = require('underscore'), | |
endpoints = require('@bunsen/libraries/endpoints'), | |
Transaction = require('@bunsen/models/ecomm/Transaction'); | |
_.extend(Shipment.prototype, { | |
idAttribute: "id", | |
url : function () { | |
return endpoints.shipment(this.get(this.idAttribute)); | |
}, | |
relations: SoaModel.createRelations([ | |
{ | |
type: Backbone.One, | |
key: 'transaction', | |
relatedModel: Transaction, | |
} | |
]) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
"use strict"; | |
bunsen.Shipment = bunsen.SoaModel.extend({ | |
idAttribute: "id", | |
url : function () { | |
return endpoints.shipment(this.get(this.idAttribute)); | |
}, | |
relations: bunsen.SoaModel.createRelations([ | |
{ | |
type: Backbone.One, | |
key: 'transaction', | |
relatedModel: 'bunsen.Transaction', | |
} | |
]) | |
}); | |
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var SoaModel = require('@bunsen/models/SoaModel'), | |
Transaction = SoaModel.extend(); | |
module.exports = bunsen.Transaction = Transaction; | |
var Backbone = require('Backbone'), | |
_ = require('underscore'), | |
endpoints = require('@bunsen/libraries/endpoints'), | |
Offer = require('@bunsen/models/ecomm/Offer'), | |
Offers = require('@bunsen/collections/ecomm/Offers'), | |
CurrencyConversionRate = require('@bunsen/models/ecomm/CurrencyConversionRate'), | |
Shipment = require('@bunsen/models/ecomm/Shipment'); | |
_.extend(Transaction.prototype, { | |
idAttribute: "id", | |
url : function () { | |
return endpoints.transaction(this.get(this.idAttribute)); | |
}, | |
relations: SoaModel.createRelations([ | |
{ | |
type: Backbone.Many, | |
key: 'offers', | |
relatedModel: Offer, | |
collectionType: Offers | |
}, | |
{ | |
type: Backbone.Many, | |
key: 'currencyConversionRates', | |
relatedModel: CurrencyConversionRate | |
}, | |
{ | |
type: Backbone.One, | |
key: 'shipment', | |
relatedModel: Shipment | |
} | |
]), | |
createOffer: function () { | |
var offer = new Offer({ | |
amount: 1234 | |
}); | |
return offer.save(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
"use strict"; | |
bunsen.Transaction = bunsen.SoaModel.extend({ | |
idAttribute: "id", | |
url : function () { | |
return endpoints.transaction(this.get(this.idAttribute)); | |
}, | |
relations: bunsen.SoaModel.createRelations([ | |
{ | |
type: Backbone.Many, | |
key: 'offers', | |
relatedModel: 'bunsen.Offer', | |
collectionType: 'bunsen.Offers' | |
}, | |
{ | |
type: Backbone.Many, | |
key: 'currencyConversionRates', | |
relatedModel: 'bunsen.CurrencyConversionRate' | |
}, | |
{ | |
type: Backbone.One, | |
key: 'shipment', | |
relatedModel: bunsen.Shipment | |
} | |
]), | |
createOffer: function () { | |
var offer = new bunsen.Offer({ | |
amount: 1234 | |
}); | |
return offer.save(); | |
} | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assume bunsen.Shipment also has a relation to bunsen.Transaction.
Issues:
Questions