   emit: (args..., value) ->
     @emitted = true
     key = args.join consts.arg_sep
-    @db.set key, JSON.stringify(value)
+    json = value?.toJSON?() ? value
+    @db.set key, JSON.stringify(json)
     @db.publish @resp_channel, key
 
   # If we've seen this `@for_reals` before, then blow right past it.

      value
    else
      @deps.push key
      undefined
  
  # Make sure the given key is being requested in a totally legal and consistent way.

  # If a klass is given, construct a new one; otherwise, just return
  # the raw value.
  build: (value, klass) ->
    klass ?= @wrapper_class
    if klass? then @bless(new klass(value)) else value
  
  # Extend the given object with the context methods of a worker,
