Commit 1e8a16c

mo khan <mo@mokhan.ca>
2013-11-09 16:13:22
split out specification to a separate file.
1 parent 4ab92f9
src/movie.coffee
@@ -1,3 +1,5 @@
+WhereSpecification = require('./specification')
+
 module.exports = class Movie
   constructor: (attributes) ->
     @title = attributes['title']
@@ -10,23 +12,3 @@ module.exports = class Movie
   @where: (condition) ->
     new WhereSpecification(condition)
 
-class OrSpecification
-  constructor: (left, right) ->
-    @left = left
-    @right = right
-
-  matches: (item) ->
-    @left.matches(item) || @right.matches(item)
-
-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)
-
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)
+