summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-11-09 09:37:30 -0700
committermo khan <mo@mokhan.ca>2013-11-09 09:37:30 -0700
commitce8541d330d7ff56bfb4c2c52d542ac68ab89acd (patch)
tree15d7e89121d6455506e56458fa0eba6f77fb0550
parent1e8a16cea7b21a7c48d8727bd4600ac598af2bd0 (diff)
split out specifications to separate files.
-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