Skip to content

Commit

Permalink
closes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Contra committed Mar 24, 2016
1 parent b7b1c6a commit 4843062
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 8 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

Object.defineProperty(exports, "__esModule", {
value: true
});
Expand All @@ -21,19 +25,21 @@ var _lodash2 = _interopRequireDefault(_lodash);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var resourceToActions = function resourceToActions(resourceName, resource) {
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

var model = new _normalizr.Schema(resourceName);
// model.define(mapValues(resource.model.relationships, relationshipMap))

return (0, _lodash2.default)(resource.endpoints, function (prev, _endpoint) {
prev[_endpoint.name] = (0, _tahoe.createAction)({
prev[_endpoint.name] = (0, _tahoe.createAction)((0, _extends3.default)({
endpoint: function endpoint(opt) {
return (0, _templateUrl2.default)(_endpoint.path, opt);
},
method: _endpoint.method,
model: model,
collection: !_endpoint.instance,
credentials: 'include'
});
}, options));
return prev;
}, {});
};
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Schema } from 'normalizr'
import template from 'template-url'
import reduce from 'lodash.reduce'

const resourceToActions = (resourceName, resource) => {
let model = new Schema(resourceName)
const resourceToActions = (resourceName, resource, options = {}) => {
const model = new Schema(resourceName)
// model.define(mapValues(resource.model.relationships, relationshipMap))

return reduce(resource.endpoints, (prev, endpoint) => {
Expand All @@ -14,7 +14,8 @@ const resourceToActions = (resourceName, resource) => {
method: endpoint.method,
model: model,
collection: !endpoint.instance,
credentials: 'include'
credentials: 'include',
...options
})
return prev
}, {})
Expand Down

0 comments on commit 4843062

Please sign in to comment.