Class: Bogus::CopiesConstructor

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

Instance Method Summary collapse

Methods included from Takes

takes

Instance Method Details

#body(initializer) ⇒ Object



13
14
15
16
# File 'lib/bogus/fakes/constructor_methods.rb', line 13

def body(initializer)
  body = method_stringifier.stringify(initializer, "super")
  body.gsub("initialize", "new")
end

#copy(from, into) ⇒ Object



6
7
8
9
10
11
# File 'lib/bogus/fakes/constructor_methods.rb', line 6

def copy(from, into)
  return unless from.is_a?(Class)
  initializer = instance_methods.call(from).get(:initialize)
  body = body(initializer)
  class_methods.call(into).define(body)
end