Sinatra Switch
Set and retrieve an arbitrary switch flag via get and post.
Use
require "sinatra/switch"
use_switch "light", { :file_location => "/tmp" }
Functionality
This will expose:
A route to get the current state of the switch:
/switch/light
A route for flicking the switch to ON:
/switch/light/on
A route for flicking the switch to OFF:
/switch/light/off
Switch state possibilities
The switch state is stored in a file:
/tmp/light_switch
File doesn't exist
switch is on
File contains ON
switch is on
File contains OFF
server is off