Permalink
Browse files

Changes ObjectPool to support non-remotes, instanced and non-instance…

…d objects
  • Loading branch information...
pnegri committed Jan 20, 2012
1 parent e38cf57 commit 600bc6b65b35dfb23fcef80260c9610ab9905641
Showing with 39 additions and 7 deletions.
  1. +6 −2 lib/arcabouco.coffee
  2. +32 −4 lib/arcabouco_modules/objectpool.coffee
  3. +1 −1 package.json
View
@@ -61,9 +61,13 @@ class Arcabouco
return false unless @ObjectPool
@ObjectPool.build( this, development )
- registerObject : ( filename, options = 0 ) ->
+ registerObject : ( object, options = {} ) ->
return false unless @ObjectPool
- @ObjectPool.registerObject filename, options
+ @ObjectPool.registerObject object, options
+
+ getObject : ( object ) ->
+ return false unless @ObjectPool
+ @ObjectPool.getObject object
#registerObject : null
#createObject : null
@@ -6,13 +6,41 @@ class ArcaboucoObjectPool
piecesArray : []
objects : []
- registerObject: ( pieceFilename, options ) ->
+ registerObject: ( object, options = {} ) ->
priority = 0
priority = options.priority if options.priority
- @piecesArray.push
- filename: pieceFilename
- priority: priority
+ remote = false
+ remote = options.remote if options.remote
+
+ name = ""
+ name = options.name if options.name
+
+ # TODO: Object Register must detect if its a file or object
+ if remote or (typeof(object) == "string")
+ @piecesArray.push
+ filename: object
+ priority: priority
+ else
+ ArcaboucoObject = object
+ isInstanceable = false
+ try
+ instanceObject = new ArcaboucoObject()
+ if instanceObject.isObject
+ isInstanceable = true
+
+ @objects[ name ] = (
+ object: object
+ instanceable: isInstanceable
+ )
+
+ getObject: ( object ) ->
+ return false unless @objects[ object ]
+
+ if @objects[ object ].instanceable
+ return new @objects[ object ]['object']
+ else
+ return @objects[ object ]['object']
build: (application, development=false) ->
View
@@ -1,7 +1,7 @@
{
"name" : "arcabouco-js",
"description" : "scalable microframework in node.js",
- "version" : "0.8.0",
+ "version" : "0.8.1",
"author" : "Patrick Negri <patrick@iugu.com.br>",
"homepage": "http://github.com/pnegri/arcabouco-js",
"contributors" : [],

0 comments on commit 600bc6b

Please sign in to comment.