Skip to content

Commit

Permalink
BEM Entity converter for checkers
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKashlakov committed Jul 3, 2016
1 parent 7b59cd3 commit 1e02782
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var Filter = require('./filter'),
var _ = require('lodash'),
Filter = require('./filter'),
Criteria = require('./criteria/criteria'),
CriteriaCollection = require('./criteria/criteria-collection');

Expand Down Expand Up @@ -94,8 +95,16 @@ exports.getFiltersForConditions = function(conditions) {
return new Filter(criteria);
}),
apply = function(item) {
// Prepare BEM entity for check
var prepareBemEntity = function(item) {
var bemEntity = _.omit(item, _.isObject);
return _.reduce(_.values(_.pick(item, _.isObject)), function(result, currentItem) {
return _.merge(result, currentItem);
}, bemEntity);
};

return filters.some(function(filter) {
return filter.apply(item);
return filter.apply(prepareBemEntity(item));
});
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"JSONStream": "^1.0.7",
"bem-config": "git://github.com/bem-incubator/bem-config.git",
"bem-naming": "^0.5.1",
"bem-walk": "0.0.4",
"bem-walk": "1.0.0-1",
"chalk": "^1.1.1",
"coa": "^1.0.1",
"flow-tostring": "^1.0.1",
Expand Down

0 comments on commit 1e02782

Please sign in to comment.