Commit ce8541d

mo khan <mo@mokhan.ca>
2013-11-09 16:37:30
split out specifications to separate files.
1 parent 1e8a16c
src/movie.coffee
@@ -1,4 +1,4 @@
-WhereSpecification = require('./specification')
+WhereSpecification = require('./where_specification')
 
 module.exports = class Movie
   constructor: (attributes) ->
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)
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)
-
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