This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
swap /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Tue Sep 22 10:56:01 -0700 2009 | |
| |
LICENSE | Sun Mar 15 22:34:08 -0700 2009 | |
| |
README | Tue Sep 22 10:36:19 -0700 2009 | |
| |
Rakefile | Tue Sep 22 10:55:08 -0700 2009 | |
| |
TODO | Sun Mar 15 21:04:24 -0700 2009 | |
| |
docs.watchr | Tue Sep 22 10:56:01 -0700 2009 | |
| |
examples/ | Wed Sep 23 07:31:37 -0700 2009 | |
| |
gem.watchr | Tue Sep 22 11:01:30 -0700 2009 | |
| |
lib/ | Tue Sep 22 10:20:50 -0700 2009 | |
| |
specs.watchr | Tue Sep 22 10:28:50 -0700 2009 | |
| |
swap.gemspec | Wed Sep 23 07:33:34 -0700 2009 | |
| |
test/ | Wed Sep 23 12:22:45 -0700 2009 |
README
==== 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







