Class: Bogus::CreatesFakes

Inherits:
Object
  • Object
show all
Extended by:
Takes
Defined in:
lib/bogus/fakes/creates_fakes.rb

Defined Under Namespace

Classes: UnknownMode

Instance Method Summary collapse

Methods included from Takes

takes

Instance Method Details

#create(name, opts = {}, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bogus/fakes/creates_fakes.rb', line 9

def create(name, opts = {}, &block)
  klass = self.klass(name, &block)
  duck = make_duck(klass)
  klass_copy = copies_classes.copy(duck)

  mode = opts.fetch(:as, :instance)

  case mode
  when :instance
    return klass_copy.__create__
  when :class
    return klass_copy
  else
    raise UnknownMode.new("Unknown fake creation mode: #{mode}. Allowed values are :instance, :class")
  end
end