Skip to content

Commit ab0394b

Browse files
committed
Begin move to using "class" keyword for more explicit code.
1 parent a34e2ae commit ab0394b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

chapters/design_patterns/builder.textile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ Create a Builder to encapsulate the object production process.
1515
The <a href="http://todotxt.com">Todo.txt</a> format provides an advanced but still plain-text method for maintaining lists of to-do items. Typing out each item by hand would provide exhausting and error-prone, however, so a TodoTxtBuilder class could save us the trouble:
1616

1717
{% highlight coffeescript %}
18-
TodoTxtBuilder = (defaultParameters={ }) ->
19-
date: new Date(defaultParameters.date) or new Date
20-
contexts: defaultParameters.contexts or [ ]
21-
projects: defaultParameters.projects or [ ]
22-
priority: defaultParameters.priority or undefined
18+
class TodoTxtBuilder
19+
constructor: (defaultParameters={ }) ->
20+
@date = new Date(defaultParameters.date) or new Date
21+
@contexts = defaultParameters.contexts or [ ]
22+
@projects = defaultParameters.projects or [ ]
23+
@priority = defaultParameters.priority or undefined
2324
newTodo: (description, parameters={ }) ->
2425
date = (parameters.date and new Date(parameters.date)) or @date
2526
contexts = @contexts.concat(parameters.contexts or [ ])

0 commit comments

Comments
 (0)