Permalink
Browse files

Fixed decorator sample (thanks tixz)

* TextDecorator was written in JavaScript-style function assignment,
  making the @processors variable drop out of scope

* Rewrote it as class TextDecorator and included a constructor to set
  the var
  • Loading branch information...
1 parent cbe19ff commit 50ab300204df022fedf51ba5117627d01199c31c @dbrady dbrady committed Feb 28, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 chapters/design_patterns/decorator.md
@@ -26,7 +26,9 @@ miniMarkdown = (line) ->
stripComments = (line) ->
line.replace /\s*\/\/.*$/, '' # Removes one-line, double-slash C-style comments
-TextProcessor = (@processors) ->
+class TextProcessor
+ constructor: (@processors) ->
+
reducer: (existing, processor) ->
if processor
processor(existing or '')

0 comments on commit 50ab300

Please sign in to comment.