Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/camertron/transfigure
An experimental Ruby native extension that allows changing an object's class at runtime.
https://github.com/camertron/transfigure
Last synced: 18 days ago
JSON representation
An experimental Ruby native extension that allows changing an object's class at runtime.
- Host: GitHub
- URL: https://github.com/camertron/transfigure
- Owner: camertron
- License: mit
- Created: 2023-06-11T21:13:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-11T21:28:23.000Z (over 1 year ago)
- Last Synced: 2024-11-04T00:42:21.736Z (2 months ago)
- Language: Ruby
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## transfigure
An experimental Ruby native extension that allows changing an object's class at runtime.
## Installation
`gem install transfigure`
## Usage
```ruby
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:
```ruby
class Foo
endclass Bar
endobj = 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
* Cameron C. Dutro: http://github.com/camertron