Sha256: b70bd9fa654cf727a931ba310c2ce42d019c0437f32b620c1a0eb176da38cdf4

Contents?: true

Size: 324 Bytes

Versions: 12

Compression:

Stored size: 324 Bytes

Contents

class Bogus::OverwritesClasses
  def overwrite(full_name, new_klass)
    modules = full_name.split('::')
    klass_name = modules.pop
    parent_module = modules.reduce(Object) { |mod, name| mod.const_get(name) }
    parent_module.send(:remove_const, klass_name)
    parent_module.const_set(klass_name, new_klass)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bogus-0.1.7 lib/bogus/fakes/overwrites_classes.rb
bogus-0.1.6 lib/bogus/fakes/overwrites_classes.rb
bogus-0.1.5 lib/bogus/fakes/overwrites_classes.rb
bogus-0.1.4 lib/bogus/fakes/overwrites_classes.rb
bogus-0.1.3 lib/bogus/overwrites_classes.rb
bogus-0.1.2 lib/bogus/overwrites_classes.rb
bogus-0.1.1 lib/bogus/overwrites_classes.rb
bogus-0.1.0 lib/bogus/overwrites_classes.rb
bogus-0.0.4 lib/bogus/overwrites_classes.rb
bogus-0.0.3 lib/bogus/overwrites_classes.rb
bogus-0.0.3.rc.2 lib/bogus/overwrites_classes.rb
bogus-0.0.3.rc.1 lib/bogus/overwrites_classes.rb