Refine media state machine methods
|Reported by:||koopersmith||Owned by:|
Currently, the media state machine has a set of most unfortunately named methods — get and state — where get( id ) returns a state, state() returns the current state, and state( id ) sets the current state. The biggest problem here is get, which is often confusing, and returns a result that itself has a get method (calling get('a').get('b') becomes a bit opaque). This is compounded by the fact that state() returns the current state, and actually has a sensible name, so it's easy to slip and think that state( id ) will return a state as well. Lastly, the mostly unused previous() can be renamed to the more verbose lastState().
So, let's fix that. This is mostly just renaming:
- state( id ) becomes setState( id )
- get( id ) becomes state( id )
- state() stays the same
- previous() becomes lastState()
Why now? get() is such a common method name, that by leaving this be, we'll effectively never be able to add a get() method to the media frame — the main object you interact with. It's now or never.
How to test this? Just play around with media in its various incarnations, keep an eye out for errors.