summaryrefslogtreecommitdiff
path: root/src/specification.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'src/specification.coffee')
-rw-r--r--src/specification.coffee20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/specification.coffee b/src/specification.coffee
new file mode 100644
index 0000000..3cdd1dc
--- /dev/null
+++ b/src/specification.coffee
@@ -0,0 +1,20 @@
+module.exports = class OrSpecification
+ constructor: (left, right) ->
+ @left = left
+ @right = right
+
+ matches: (item) ->
+ @left.matches(item) || @right.matches(item)
+
+module.exports = class WhereSpecification
+ constructor: (condition) ->
+ @condition = condition
+
+ matches: (item) ->
+ for key in Object.keys(@condition)
+ return false if item[key] != @condition[key]
+ return true
+
+ or: (other_specification) ->
+ new OrSpecification(this, other_specification)
+