Sha256: 05307913711120f8f4d1811c1ae1650ac9c7bf647bf32cf21171532ef70ed954
Contents?: true
Size: 706 Bytes
Versions: 3
Compression:
Stored size: 706 Bytes
Contents
module Bogus class CreatesFakes class UnknownMode < RuntimeError; end extend Takes takes :copies_classes, :converts_name_to_class def create(name, opts = {}, &block) klass = self.klass(name, &block) klass_copy = copies_classes.copy(klass) mode = opts.fetch(:as, :instance) case mode when :instance return klass_copy.new when :class return klass_copy else raise UnknownMode.new("Unknown fake creation mode: #{mode}. Allowed values are :instance, :class") end end protected def klass(name, &block) return block.call if block_given? converts_name_to_class.convert(name) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bogus-0.0.3.rc.1 | lib/bogus/creates_fakes.rb |
bogus-0.0.2 | lib/bogus/creates_fakes.rb |
bogus-0.0.1 | lib/bogus/creates_fakes.rb |