Skip to content

Commit

Permalink
actual solution to #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Contra committed Mar 24, 2016
1 parent 4843062 commit deef5f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ 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 resourceToActions = function resourceToActions(resourceName, resource, options) {
var model = new _normalizr.Schema(resourceName);
// model.define(mapValues(resource.model.relationships, relationshipMap))

Expand All @@ -45,8 +43,9 @@ var resourceToActions = function resourceToActions(resourceName, resource) {
};

exports.default = function (resources) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
return (0, _lodash2.default)(resources.toJS ? resources.toJS() : resources, function (prev, v, k) {
prev[(0, _pluralize.plural)(k)] = resourceToActions(k, v);
prev[(0, _pluralize.plural)(k)] = resourceToActions(k, v, options);
return prev;
}, {});
};
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Schema } from 'normalizr'
import template from 'template-url'
import reduce from 'lodash.reduce'

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

Expand All @@ -21,8 +21,8 @@ const resourceToActions = (resourceName, resource, options = {}) => {
}, {})
}

export default (resources) =>
export default (resources, options = {}) =>
reduce((resources.toJS ? resources.toJS() : resources), (prev, v, k) => {
prev[plural(k)] = resourceToActions(k, v)
prev[plural(k)] = resourceToActions(k, v, options)
return prev
}, {})

0 comments on commit deef5f3

Please sign in to comment.