PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/js/TestPacket.js

https://bitbucket.org/juliand89/firewall-game
JavaScript | 25 lines | 18 code | 2 blank | 5 comment | 0 complexity | 7368d93737041d050d55a154496993b4 MD5 | raw file
  1. var TestPacket = Backbone.Model.extend({
  2. defaults: function () {
  3. return {
  4. packet: new Packet(),
  5. shouldPass: true,
  6. passMsg: '',
  7. failMsg: ''
  8. };
  9. },
  10. // The built-in clone method calls the model's constructor with the model's
  11. // `attributes` attribute passed in. This causes the model constructor to
  12. // receive a packet attribute in the form of a Packet instance instead of a
  13. // JSON object. (the to-be-cloned mode's constructor converted the JSON
  14. // object it recieved into a packet instance)
  15. clone: function () {
  16. var attributes = _.clone(this.attributes);
  17. attributes.packet = attributes.packet.toJSON();
  18. return new TestPacket(attributes);
  19. }
  20. });
  21. var TestPackets = Backbone.Collection.extend({
  22. model: TestPacket
  23. });