1
0
Fork 0
mirror of https://github.com/ms-ati/docile synced 2023-03-27 23:21:52 -04:00

Update README.md

Without returning `self` this example fail.
This commit is contained in:
Xavier Nayrac 2013-08-01 13:15:53 +02:00
parent f0f1c5f2cc
commit 3384ac962e

View file

@ -66,10 +66,10 @@ And let's say we have a PizzaBuilder, which builds a Pizza like this:
Pizza = Struct.new(:cheese, :pepperoni, :bacon, :sauce) Pizza = Struct.new(:cheese, :pepperoni, :bacon, :sauce)
class PizzaBuilder class PizzaBuilder
def cheese(v=true); @cheese = v; end def cheese(v=true); @cheese = v; self; end
def pepperoni(v=true); @pepperoni = v; end def pepperoni(v=true); @pepperoni = v; self; end
def bacon(v=true); @bacon = v; end def bacon(v=true); @bacon = v; self; end
def sauce(v=nil); @sauce = v; end def sauce(v=nil); @sauce = v; self; end
def build def build
Pizza.new(!!@cheese, !!@pepperoni, !!@bacon, @sauce) Pizza.new(!!@cheese, !!@pepperoni, !!@bacon, @sauce)
end end