apeckham / switches

Runtime switches for a Rails app

This URL has Read+Write access

name age message
file README Tue Nov 11 16:14:19 -0800 2008 ap - added readme [apeckham]
file Rakefile Tue Nov 11 14:54:59 -0800 2008 ap - first commit [apeckham]
file init.rb Fri Feb 06 13:29:02 -0800 2009 ap - added init file [apeckham]
directory lib/ Tue Feb 17 16:39:16 -0800 2009 ap - use default if switch content is the empty... [apeckham]
directory tasks/ Tue Nov 11 14:54:59 -0800 2008 ap - first commit [apeckham]
directory test/ Tue Feb 17 16:39:16 -0800 2009 ap - use default if switch content is the empty... [apeckham]
README
switches - Runtime switches for a Rails app

Sometimes I want to turn on and off features of my application without code changes. For example, sometimes my 
application runs in read-only mode, but most of the time it's in read-write mode. In read-only mode I want certain 
features to not appear.

This code uses files on disk to determine whether a switch is enabled. Create your own switch by extending Switch::Base:


class ReadOnlySwitch < Switch::Base
end

Then turn it on with ReadOnlySwitch.turn_on. Wherever behavior should change based on whether the switch is on, use "if 
ReadOnlySwitch.is_on?"

The files on disk that indicate whether a switch is on are stored in config/switch.