Commit dcdb607

mo khan <mo@mokhan.ca>
2013-11-09 16:45:47
extract criteria.
1 parent ce8541d
src/criteria.coffee
@@ -0,0 +1,6 @@
+WhereSpecification = require('./where_specification')
+
+module.exports = Criteria =
+  where: (condition) ->
+    new WhereSpecification(condition)
+
src/module.coffee
@@ -8,3 +8,9 @@ module.exports = class Module
     object.included?.apply(@)
     this
 
+  @extend: (object) ->
+    for key, value of object when key not in moduleKeywords
+      @[key] = value
+
+    object.extended?.apply(@)
+    this
src/movie.coffee
@@ -1,6 +1,9 @@
-WhereSpecification = require('./where_specification')
+Module = require('./module')
+Criteria = require('./criteria')
+
+module.exports = class Movie extends Module
+  @extend Criteria
 
-module.exports = class Movie
   constructor: (attributes) ->
     @title = attributes['title']
     @studio = attributes['studio']
@@ -8,7 +11,3 @@ module.exports = class Movie
 
   equals: (other) ->
     @title == other["title"]
-
-  @where: (condition) ->
-    new WhereSpecification(condition)
-