lib/bogus/creates_fakes.rb in bogus-0.0.3.rc.1 vs lib/bogus/creates_fakes.rb in bogus-0.0.3.rc.2
- old
+ new
@@ -2,15 +2,16 @@
class CreatesFakes
class UnknownMode < RuntimeError; end
extend Takes
- takes :copies_classes, :converts_name_to_class
+ takes :copies_classes, :converts_name_to_class, :makes_ducks
def create(name, opts = {}, &block)
klass = self.klass(name, &block)
- klass_copy = copies_classes.copy(klass)
+ duck = make_duck(klass)
+ klass_copy = copies_classes.copy(duck)
mode = opts.fetch(:as, :instance)
case mode
when :instance
@@ -25,8 +26,13 @@
protected
def klass(name, &block)
return block.call if block_given?
converts_name_to_class.convert(name)
+ end
+
+ def make_duck(klass)
+ return klass unless klass.is_a?(Array)
+ makes_ducks.make(*klass)
end
end
end