author | nowmad@23.1.168.192.in-addr.arpa |
Thu, 17 Dec 2015 12:21:50 +0100 | |
changeset 69 | 87946963c3bb |
parent 63 | 43a8a7893e35 |
child 90 | f0609941aa98 |
permissions | -rw-r--r-- |
42
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
1 |
import DS from 'ember-data'; |
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
2 |
|
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
3 |
export default DS.FixtureAdapter.extend({ |
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
4 |
host: 'http://127.0.0.1', |
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
5 |
namespace: 'api', |
69
87946963c3bb
add queryFixture to be able to simulate query on the fixtures data
nowmad@23.1.168.192.in-addr.arpa
parents:
63
diff
changeset
|
6 |
queryFixtures: function(records, query, type) { |
87946963c3bb
add queryFixture to be able to simulate query on the fixtures data
nowmad@23.1.168.192.in-addr.arpa
parents:
63
diff
changeset
|
7 |
return records.filter(function(record) { |
87946963c3bb
add queryFixture to be able to simulate query on the fixtures data
nowmad@23.1.168.192.in-addr.arpa
parents:
63
diff
changeset
|
8 |
for(var key in query) { |
87946963c3bb
add queryFixture to be able to simulate query on the fixtures data
nowmad@23.1.168.192.in-addr.arpa
parents:
63
diff
changeset
|
9 |
if (!query.hasOwnProperty(key)) { continue; } |
87946963c3bb
add queryFixture to be able to simulate query on the fixtures data
nowmad@23.1.168.192.in-addr.arpa
parents:
63
diff
changeset
|
10 |
var value = query[key]; |
87946963c3bb
add queryFixture to be able to simulate query on the fixtures data
nowmad@23.1.168.192.in-addr.arpa
parents:
63
diff
changeset
|
11 |
if (record[key] !== value) { return false; } |
87946963c3bb
add queryFixture to be able to simulate query on the fixtures data
nowmad@23.1.168.192.in-addr.arpa
parents:
63
diff
changeset
|
12 |
} |
87946963c3bb
add queryFixture to be able to simulate query on the fixtures data
nowmad@23.1.168.192.in-addr.arpa
parents:
63
diff
changeset
|
13 |
return true; |
87946963c3bb
add queryFixture to be able to simulate query on the fixtures data
nowmad@23.1.168.192.in-addr.arpa
parents:
63
diff
changeset
|
14 |
}); |
87946963c3bb
add queryFixture to be able to simulate query on the fixtures data
nowmad@23.1.168.192.in-addr.arpa
parents:
63
diff
changeset
|
15 |
} |
42
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
16 |
}); |