Last active
April 28, 2017 00:31
-
-
Save mmun/559a1a2f57e7a0b1b9f40dd382d63d1a to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or 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
import DS from 'ember-data'; | |
export default DS.JSONAPIAdapter; |
This file contains hidden or 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
import DS from 'ember-data'; | |
export default DS.RESTAdapter; |
This file contains hidden or 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
import ActiveModelAdapter from 'active-model-adapter'; | |
export default ActiveModelAdapter; |
This file contains hidden or 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
console.clear(); | |
import Ember from 'ember'; | |
import { task } from 'ember-concurrency'; | |
// Setup pretender | |
new Pretender(function() { | |
this.post('/cats', function(request) { | |
let payload = JSON.parse(request.requestBody); | |
// Just passes the errors object through as is. | |
return [payload.data.attributes.status, {}, JSON.stringify({ | |
errors: [{ | |
detail: "Not enough meow", | |
source: { pointer: 'data/attributes/meow_meow_meow' } | |
}] | |
})]; | |
}); | |
this.post('/dogs', function(request) { | |
let payload = JSON.parse(request.requestBody); | |
// Just passes the errors object through as is. | |
return [payload.dog.status, {}, JSON.stringify({ | |
errors: [{ | |
detail: "Not enough woof", | |
source: { pointer: 'data/attributes/woof_woof_woof' } | |
}] | |
})]; | |
}); | |
this.post('/frogs', function(request) { | |
let payload = JSON.parse(request.requestBody); | |
// Doesn't support JSON-API. | |
return [payload.frog.status, {}, JSON.stringify({ | |
errors: { | |
foo_bar_zaz: ['wtf', 'lol'] | |
} | |
})]; | |
}); | |
}); | |
export default Ember.Controller.extend({ | |
createCat: task(function*(status) { | |
this.set('cat', this.store.createRecord('cat', { status })); | |
return this.get('cat').save(); | |
}), | |
createDog: task(function*(status) { | |
this.set('dog', this.store.createRecord('dog', { status })); | |
return this.get('dog').save(); | |
}), | |
createFrog: task(function*(status) { | |
this.set('frog', this.store.createRecord('frog', { status })); | |
return this.get('frog').save(); | |
}) | |
}); |
This file contains hidden or 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
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
status: attr(), | |
meowMeowMeow: attr() | |
}); |
This file contains hidden or 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
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
status: attr(), | |
woofWoofWoof: attr() | |
}); |
This file contains hidden or 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
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
status: attr(), | |
ribbitRibbit: attr() | |
}); |
This file contains hidden or 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
td, th { | |
text-align: center; | |
padding: 0.5em; | |
} |
This file contains hidden or 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
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0", | |
"route-recognizer": "https://rawgit.com/tildeio/route-recognizer/56f5fcec6ae58d8e86b5dc77609809fb91198142/dist/route-recognizer.js", | |
"FakeXMLHttpRequest": "https://rawgit.com/pretenderjs/FakeXMLHttpRequest/23c3a96b5b24f1bfe595867437e4f128a29c2840/fake_xml_http_request.js", | |
"pretender": "https://rawgit.com/pretenderjs/pretender/c6de9afe18b1472aded2592f5a80ad9a26a0e262/pretender.js" | |
}, | |
"addons": { | |
"active-model-adapter": "2.1.1", | |
"ember-concurrency": "0.8.1", | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment