0.0
No release in over a year
An experimental Ruby native extension that allows changing an object's class at runtime.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

transfigure

An experimental Ruby native extension that allows changing an object's class at runtime.

Installation

gem install transfigure

Usage

require 'transfigure'

The transfigure gem adds the transfigure_into! method onto Ruby's Object class. Pass it another class to switch out the object's current class to another one:

class Foo
end

class Bar
end

obj = Foo.new
obj.is_a?(Foo) # => true
obj.transfigure_into!(Bar)
obj.is_a?(Foo) # => false
obj.is_a?(Bar) # => true

Requirements

The code has only been tested on MRI (cruby) 3.1 and will definitely not work on other Ruby engines like JRuby or TruffleRuby.

Running Tests

bundle exec rspec

Authors