lib/dicer/contextable.rb in dicer-0.1.0 vs lib/dicer/contextable.rb in dicer-0.2.0
- old
+ new
@@ -8,10 +8,18 @@
else
block.call(context.supply(self))
end
end
- def as(*behaviors, &block)
+ def as(role, context, &block)
+ if block.nil?
+ context.supply(self, role)
+ else
+ block.call(context.supply(self, role))
+ end
+ end
+
+ def behaves_like(*behaviors, &block)
delegator = Dicer::Delegator.make(self.class, behaviors)
block.nil? ? delegator.new(self) : block.call(delegator.new(self))
end
end