qandidate-labs/qandidate-toggle — pull request #8 by ericdowell (2014-10-09 20:17:04+00:00)
Title: Adding update method to ToggleCollection abstract class

I found a workaround to not having an update method in ToggleCollection, but I really don't like workarounds. My application is using Redis and needs an easy way to detect when a toggle name is changed so I can delete the old record and use the new name when getting the toggle.

Workaround:
```php
//class AppCollection extends ToggleCollection
//...
public function set( $name, Toggle $toggle ) {
$remove = false;
$removeName = $name;
$trace = debug_backtrace();
$caller = $trace[1];

if( strstr( $caller[ 'function' ] , 'update' ) ) {
extract( $this->checkNameChange( $name , $toggle ) ); //returns [ 'name' => $name , 'toggle' => $this->serializer->deserialize( $toggle ) , 'remove' => $remove ]
if( $remove ) $this->remove( $removeName );
}
$this->client->set( $this->namespace . '__TOGGLE__' . $name, serialize( $toggle ) );
}
//...
```

ToggleCollection will then also have 'GET' (get), 'POST' (set), 'PUT' (update), and 'DELETE' (remove) methods.