-
Notifications
You must be signed in to change notification settings - Fork 0
Ruby lib that allows dynamically replacing and restoring methods
License
mynyml/swap
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
==== Summary Swap allows dynamically replacing and restoring methods. Useful as a stubbing device, as it allows unstubbing as well. ==== Examples require 'swap' class User extend Swappable attr_writer :name def name @name end end user = User.new user.name = 'martin' user.name #=> 'martin' User.swap!(:name) { @name.reverse } user.name #=> 'nitram' User.unswap!(:name) user.name #=> 'martin' Calling #unswap! without argument will restore all swapped methods. See also examples/simple.rb
About
Ruby lib that allows dynamically replacing and restoring methods
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published