Decorators in Scale

# our class (can be anything..., think rendering, or stream processing)

class Coffee     def cost         1.50     end end

# our decorators

jack :milk do     def cost         super() + 0.30     end end jack :vanilla do     def cost         super() + 0.15     end end

# the coffee

cup = Coffee.new.enrich(milk, vanilla, vanilla) # this list can....

# our tests

cup.cost.should == 2.10 cup.injectors.sym_list.should == [:milk, :vanilla, :vanilla]

# coffee is coffee

cup.should be_instance_of(Coffee)

For more info check out: http://blog.jackbox.us/2015/09/decorators-in-scale.html