Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support for non-Function objects in helpers #100

Open
wants to merge 1 commit into from

1 participant

@grncdr

I find it useful to share objects with my request handlers via the helpers, but wrapping them in a function leads to lots of extra bracket noise.

@shimaore shimaore referenced this pull request from a commit in zappajs/zappajs
@shimaore shimaore Added support of non-function helpers [grncdr]
Commit 1be2602 in mauricemach/zappa#100 with test added.
4f510eb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 9, 2011
  1. Add support for non-Function objects in helpers

    Stephen Sugden authored
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/zappa.coffee
View
9 src/zappa.coffee
@@ -280,9 +280,12 @@ zappa.app = (func) ->
for name, helper of helpers
do (name, helper) ->
- ctx[name] = (args...) ->
- args.push ctx
- helper.apply ctx, args
+ if helper instanceof Function
+ ctx[name] = (args...) ->
+ args.push ctx
+ helper.apply ctx, args
+ else
+ ctx[name] = helper
if app.settings['databag']
data = {}
Something went wrong with that request. Please try again.