Created
February 27, 2014 22:47
-
-
Save robrichard/9261299 to your computer and use it in GitHub Desktop.
After UMD
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 (root, factory) { | |
var _export; | |
if (typeof module !== 'undefined') { | |
// CommonJS | |
factory(module, | |
require('Backbone'), | |
require('@bunsen/libraries/endpoints'), | |
require('@bunsen/models/SoaModel'), | |
require('@bunsen/collections/ecomm/Offers'), | |
require('@bunsen/models/ecomm/Offer'), | |
require('@bunsen/models/ecomm/CurrencyConversionRate'), | |
require('@bunsen/models/ecomm/Shipment'), | |
); | |
// assign export var | |
_export = module.exports; | |
} else { | |
// Use different var name to prevent hoisting | |
var m = {}; | |
// Browser globals | |
factory(m, | |
Backbone, | |
endpoints | |
bunsen.SoaModel, | |
bunsen.Offers, | |
bunsen.Offer, | |
bunsen.CurrencyConversionRate, | |
'bunsen.Shipment' | |
); | |
// assign export var | |
_export = m.exports; | |
} | |
// Set this to your module name | |
root.bunsen.Transaction = _export; | |
}(window, function (module, | |
Backbone, | |
SoaModel, | |
Offers, | |
Offer, | |
CurrencyConversionRate, | |
Shipment | |
) { | |
"use strict"; | |
var Transaction = SoaModel.extend({ | |
idAttribute: "id", | |
url : function () { | |
return endpoints.transaction(this.get(this.idAttribute)); | |
}, | |
relations: function () { | |
return [ | |
{ | |
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(); | |
} | |
}); | |
module.exports = Transaction; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment