From 1e027821c79cba1acb1e62ca44ceccf7c7dd0b27 Mon Sep 17 00:00:00 2001 From: Ilya Kashlakov Date: Sun, 3 Jul 2016 19:27:58 +0300 Subject: [PATCH] BEM Entity converter for checkers --- lib/util.js | 13 +++++++++++-- package.json | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/util.js b/lib/util.js index ffa1df9..501f04b 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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'); @@ -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)); }); }; diff --git a/package.json b/package.json index 961fc6d..77ccd39 100644 --- a/package.json +++ b/package.json @@ -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",