Navigation Menu

Skip to content

Commit

Permalink
Lazily create default app.
Browse files Browse the repository at this point in the history
  • Loading branch information
zeekay committed Jul 4, 2012
1 parent f929232 commit d8b6309
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/die.coffee
Expand Up @@ -15,8 +15,14 @@ class Die
@updateOptions 'default'
@updateOptions process.env.NODE_ENV or 'development'

# Create default app
@app = @createServer server.default(@options)
# Lazily create default app
Object.defineProperty @, 'app',
get: =>
# Replace accessor with @app
delete @app
@app = @createServer server.default(@options)
enumerable: true
configurable: true

# update options using configuration file or object
updateOptions: (options) ->
Expand All @@ -32,10 +38,10 @@ class Die
require('./build')(@options)

createServer: (func) ->
@app = server.createServer func
@_app = server.createServer func

extend: (func) ->
@app = server.extend @app, func
server.extend @app, func
@

inject: (dieApp) ->
Expand Down

0 comments on commit d8b6309

Please sign in to comment.