summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/movie.coffee2
-rw-r--r--src/or_specification.coffee12
-rw-r--r--src/specification.coffee20
-rw-r--r--src/where_specification.coffee13
4 files changed, 29 insertions, 18 deletions
diff --git a/src/movie.coffee b/src/movie.coffee
index b227dda..23dd4f4 100644
--- a/src/movie.coffee
+++ b/src/movie.coffee
@@ -1,4 +1,4 @@
-WhereSpecification = require('./specification')
+WhereSpecification = require('./where_specification')
module.exports = class Movie
constructor: (attributes) ->
diff --git a/src/or_specification.coffee b/src/or_specification.coffee
new file mode 100644
index 0000000..6fd7172
--- /dev/null
+++ b/src/or_specification.coffee
@@ -0,0 +1,12 @@
+Module = require('./module')
+Specification = require('./specification')
+
+module.exports = class OrSpecification extends Module
+ @include Specification
+
+ constructor: (left, right) ->
+ @left = left
+ @right = right
+
+ matches: (item) ->
+ @left.matches(item) || @right.matches(item)
diff --git a/src/specification.coffee b/src/specification.coffee
index 3cdd1dc..6a98feb 100644
--- a/src/specification.coffee
+++ b/src/specification.coffee
@@ -1,20 +1,6 @@
-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
+Module = require('./module')
+OrSpecification = require('./or_specification')
+module.exports = Specification =
or: (other_specification) ->
new OrSpecification(this, other_specification)
-
diff --git a/src/where_specification.coffee b/src/where_specification.coffee
new file mode 100644
index 0000000..df58646
--- /dev/null
+++ b/src/where_specification.coffee
@@ -0,0 +1,13 @@
+Module = require('./module')
+Specification = require('./specification')
+
+module.exports = class WhereSpecification extends Module
+ @include Specification
+
+ constructor: (condition) ->
+ @condition = condition
+
+ matches: (item) ->
+ for key in Object.keys(@condition)
+ return false if item[key] != @condition[key]
+ return true